Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify array of objects to 2d array #1092

Open
wangjiawen2013 opened this issue Dec 19, 2023 · 2 comments
Open

Simplify array of objects to 2d array #1092

wangjiawen2013 opened this issue Dec 19, 2023 · 2 comments

Comments

@wangjiawen2013
Copy link

wangjiawen2013 commented Dec 19, 2023

Hi, how to convert the following array of objects to 2d array for simplification in Rust ?

here is the array of objects:

[
    {"town":"t1","area":16800,"population":1600},
    {"town":"t2","area":6400,"population":1800}
]

It is expected to be:

[
    ["town","area","population"],
    ["t1",16800,1600],
    ["t2", 6400, 1800]
]
@martin-g
Copy link

It looks like you want to use CSV instead of JSON.

@wangjiawen2013
Copy link
Author

This is necessary in some cases, such as Charming (a popular rust graph library) are using 2d array json format:
https://github.com/yuankunzhang/charming/blob/main/gallery/asset/life-expectancy-table.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants