V
V
Valen962018-05-24 03:27:24
JavaScript
Valen96, 2018-05-24 03:27:24

How to parse json file?

Tell me, I'm studying react and it came to splitting and getting a json file. There is such a structure

[{
    "id": 0,
    "name": "рпрп",
    "age": 37,
    "phone": "33",
}, {
     "id": 1,
    "name": "рпрп",
    "age": 46,
    "phone": "333",
}]

It turned out to break it, but how to get a similar result from the structure below (or how best to process it, I don’t quite understand)
[{
        "main1": {
            "submain11": "text",
            "submain12": "text",
            "img": "/jpg"
        },
        "main2": {
            submain21": "text",
            "submain22": "text"
        },
        "main3": {
            "submain31": "text",
            "submain32": "text"
        },
        "main4": {
            "submain41": "text",
            "submain42": text",
            "submain43": "text",
            "submain44": "text"
        }
    },
{
        "main1": {
            "submain11": "text",
            "submain12": "text",
            "img": "/jpg"
        },
        "main2": {
            submain21": "text",
            "submain22": "text"
        },
        "main3": {
            "submain31": "text",
            "submain32": "text"
        },
        "main4": {
            "submain41": "text",
            "submain42": text",
            "submain43": "text",
            "submain44": "text"
        }
    }]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
W
Web Dentist, 2018-05-24
@kgb_zor

https://stackoverflow.com/questions/37649695/how-c...
https://www.npmjs.com/package/react-json-parser

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question