Giter Site home page Giter Site logo

json2csv's Introduction

json2csv's People

Contributors

alexwennerberg avatar anthrax1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

json2csv's Issues

Have a library to use in code

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.

json2csv doesn't work on arrays of objects

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.

Flatten doesnt work when smaller arrays are first.

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

panicks when converting json generated from serde_json

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.