0

i have this array

{
    "sEcho": 1,
    "iTotalRecords": 54,
    "iTotalDisplayRecords": 54,
    "aaData": [
        [
            "79",
            "testowy2",
            "testowy samochod",
            "12.00",
            "14.00",
            "2147483647",
            "posciel",
            ""
        ]
    ]
}

how I can parse last array with JSON in javascript?

1 Answer 1

4

What you have is a unparsed object, You can use JSON.parse() to parse it and get a object.

var obj = JSON.parse('{ "sEcho": 1, "iTotalRecords": 54, "iTotalDisplayRecords": 54, "aaData": [ [ "79", "testowy2", "testowy samochod", "12.00", "14.00", "2147483647", "posciel", "" ] ] }');

Demo

Sign up to request clarification or add additional context in comments.

20 Comments

How I can display data from 1st post?
@user3211948, then you can use obj.sEcho, or obj.iTotalRecords- did you check my demo?
Yes I checked it displays data in aaData but how I can separate each value in this data?
@user3211948 Since aaData is a array with a array inside, you first need to use aaData[0] to reach the inner array, then use numbers from 0 to reach the one you want. For example aaData[0][3] will give you "12.00"
It works thanks. Can you tell me one more thing. How can I check how many arrays are in aaData?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.