Skip to content
Advertisement

Extract data from json in these format

I’ve been messing around with JSON for some time, just pushing it out as text and it hasn’t hurt anybody (that I know of), but I’d like to start doing things properly.

this is my code :

JavaScript

this is my json file:

JavaScript

my output is these:

JavaScript

I want output like in these format as you have shown in the pic if you see in the JSON file I would like to extract name and value from the JSON file kindly what I can doing mistake please let me know

Expected Output:

enter image description here

Advertisement

Answer

Two ways to do that:

  1. You can use pandas to put that into a dataframe/table (with .json_normalize()
  2. Just use the for loop

Given data:

JavaScript

Code 1:

JavaScript

Output:

JavaScript

Code 2:

JavaScript

Output:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement