0

I have a json in my html page with the following format

{
    "data": [
        {
            "values": [
                [
                    894306600000,
                    1342
                ],
                [
                    894393000000,
                    749
                ]
            ],
            "key": "Beverages"
        }
    ]
}

i want to copy this json from one variable to another in this format

  [
        {
            "values": [
                [
                    894306600000,
                    1342
                ],
                [
                    894393000000,
                    749
                ]
            ],
            "key": "Beverages"
        }
    ]

How do i access the inner childs in this hierarchy

1 Answer 1

4

you can access child keys with the object.key or the object['key'] notation.WIth arrays, just use array[index]

var before = JSON.parse(first_JSON);
var after = before.data;
var second_JSON = JSON.stringify(after);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.