alexwennerberg / json2csv Goto Github PK
View Code? Open in Web Editor NEWConvert JSON to CSV in Rust
License: MIT License
Convert JSON to CSV in Rust
License: MIT License
I have a rust project that outputs json
data. Trying to run this to convert it into csv
, I get below error:
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /Users/nasifimtiaz/.cargo/registry/src/github.com-1ecc6299db9ec823/json2csv-0.1.0/src/convert.rs:47:14
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Probably have to do something like this but for whatever alternative json library I use serde-rs/json#404
Given the following:
[
{
"name": "michael",
"family": [
{
"name": "theodore",
"relation": "father"
}
]
},
{
"name": "john",
"family": [
{
"name": "jane",
"relation": "sister"
},
{
"name": "janet",
"relation": "mother"
}
]
}
]
jslint test.json
(node:46179) Warning: Accessing non-existent property 'runMain' of module exports inside circular dependency
(Use `node --trace-warnings ...` to show where the warning was created)
test.json is OK.
Yields the following:
RUST_BACKTRACE=1 json2csv test.json
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', /Users/ehiggs/.cargo/registry/src/github.com-1ecc6299db9ec823/json2csv-0.1.0/src/convert.rs:45:17
stack backtrace:
0: <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt
1: core::fmt::write
2: std::io::Write::write_fmt
3: std::panicking::default_hook::{{closure}}
4: std::panicking::default_hook
5: std::panicking::rust_panic_with_hook
6: rust_begin_unwind
7: core::panicking::panic_fmt
8: core::panicking::panic
9: json2csv::convert::write_json_to_csv
10: json2csv::main
11: std::rt::lang_start::{{closure}}
12: std::rt::lang_start_internal
13: main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
dont need a full library here
Given the following input:
cat test.json
{
"name": "michael",
"family": [
{
"name": "theodore",
"relation": "father"
}
]
}
{
"name": "john",
"family": [
{
"name": "jane",
"relation": "sister"
},
{
"name": "janet",
"relation": "mother"
}
]
}
Yields the following:
json2csv -F test.json
family.0.name,family.0.relation,name
theodore,father,michael
jane,sister,john
Hello,
Nice crate. Do you think it's a good idea to add a library to use it in code? I wanted to do use in my code so it will be very useful for me. I can help you to do it if you agree to do it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.