vladimiriii/jsonify-it

examples

Closed this issue · 7 comments

Hi
Do you have any csv examples with input and output parameters? I found difficult to understand the use of the jsonify it tool.

thanks

HI Ricardos,

Did you have something in particular you were trying to do that maybe I can help with? I can add some examples to the documentation, but I think for most people it is probably easier/quicker to understand what the different settings do with just some trial and error.

OK, that structure is quite complex, and I assume what you show above is just one of many 'classes'?

In terms of the CSV, there aren't too many ways that you can structure it. With a dataset like the one you show, I guess you will need one row per student, with all the levels flattened. The columns are then all the fields and you will have the class details repeated for each student in each class. Something like:

id | start | duration | room | slug | title | track_name | color | language | student_id | student_full_public_name | stuent_first_name | student_last_name

Do you currently have the data in JSON or CSV?

The parameters can be split into three main types. The first group (under step 2 - input options) are just to help ensure the data is being read in correctly. It should, in 95% of cases, not need you to change anything.

The second group (under step three - basic output options) help you define the basic structure of the JSON. The options in the drop down are all based on the Pandas to_dict function. From the sample you provide above, I think 'record' is what you want.

The third group (under step 3 - nesting options) allows you to nest the JSON output. But it is designed to nest based on 1 field at a time. Your example looks like you would need to nest by 8 fields, one of which is also nested. So for example, with a CSV input like this:

id,first_name,full_public_name,student_id,last_name
2,Andre,Andre Dantas,3039,Dantas
2,Sara,Sara Silva,3459,Silva
2,Maria,Maria Ingunza,3317,Ingunza
3,Foo,Foo Bar,3039,Bar
3,Sara,Sara Stuff,3459,Stuff
3,Maria,Maria Unknown,3317,Unknown

You can generate a JSON like this:

[
{
"count": 3,
"persons": [
{
"student_id": 3039,
"full_public_name": "Andre Dantas",
"id": 2,
"last_name": "Dantas",
"first_name": "Andre"
},
{
"student_id": 3459,
"full_public_name": "Sara Silva",
"id": 2,
"last_name": "Silva",
"first_name": "Sara"
},
{
"student_id": 3317,
"full_public_name": "Maria Ingunza",
"id": 2,
"last_name": "Ingunza",
"first_name": "Maria"
}
],
"id": 2
},
{
"count": 3,
"persons": [
{
"student_id": 3039,
"full_public_name": "Foo Bar",
"id": 3,
"last_name": "Bar",
"first_name": "Foo"
},
{
"student_id": 3459,
"full_public_name": "Sara Stuff",
"id": 3,
"last_name": "Stuff",
"first_name": "Sara"
},
{
"student_id": 3317,
"full_public_name": "Maria Unknown",
"id": 3,
"last_name": "Unknown",
"first_name": "Maria"
}
],
"id": 3
}
]