How to get JSON response array all index values?

Ajay

I need to get JSON response array all indexes values and maintain separate array. Here below I have posted my JSON response and I wanted to get console output looks like below also. Please help me.

response : [ {

        A =  [  {

                    name : "sons";
                    age = [
                                4
                          ];
                },
                {
                    name : "rondo";
                    age = [
                                2
                          ];
                },

             ];


           } ]

I need to store separate array separate values looks like below console output

2014-09-18 10:24:39.461 Myapp[1133:60b] RESULT : {
    name = "sons";
    age  = 4;
}
2014-09-18 10:24:39.462 Myapp[1133:60b] RESULT : {
    name = "rondo";
    age  = 2;
}

Here below I tried but I Know I can get only 0th index value but I need to get all index value from JSON response array:

myvalue = [NSString stringWithFormat:@"%@",[[[[responsData objectAtIndex:0] valueForKey:@"A"] objectAtIndex:0] valueForKey:@"name"]];
Mounika Vangala

if you want to get all objects, get the array using the respective key.Then store the result in another array by iterating the for loop according to array count.

NSArray *recordsArr = [[responsedata objectAtIndex:0] valueForKey:@"A"];

NSMutableArray *resultArray = [[NSMutableArray alloc] init];
for (int i = 0; i < [recordsArr count]; i ++) {
    NSMutableDictionary *recordDict = [[NSMutableDictionary alloc] init];

    [recordDict setObject:[[recordsArr objectAtIndex:i] valueForKey:@"name"] forKey:@"name"];
    [recordDict setObject:[[[recordsArr objectAtIndex:i] valueForKey:@"age"] objectAtIndex:0] forKey:@"age"];

    [resultArray addObject:recordDict];
}

NSLog(@"%@",resultArray);

output:

2014-09-18 12:49:22.047 testprj[1044:60b] (
        {
        age = 4;
        name = sons;
    },
        {
        age = 2;
        name = rondo;
    }
)

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to parse json to get all values of a specific key within an array?

分類Dev

How to get all values of objects inside array

分類Dev

How get index of array with jq

分類Dev

RestAssured: How to check the length of json array response?

分類Dev

How to get text values to an array?

分類Dev

How to get all array edges?

分類Dev

how to get valid json response from server

分類Dev

How to get Typeahead with Bloodhound to work with a JSON response?

分類Dev

How to get a json object with specific key values, from a json array column?

分類Dev

How to get values in array of array in angular?

分類Dev

In Angular 8, How to get form all values into JSON on click submit button?

分類Dev

How to count all values in a multidimensional array?

分類Dev

How to get all values in a string enum?

分類Dev

how to get all values of object via coffeescript?

分類Dev

How to get the equilibrium index of an array in O(n)?

分類Dev

How to decode SAML Response and get the attribute values sent by Idp in PHP

分類Dev

How to get all the headers from an Angular 2 response?

分類Dev

How to display json array values in single UITableVIewCell

分類Dev

how to get array values, on input field

分類Dev

How to get the values of generic array in Java?

分類Dev

Get index value of an array by it's value in PHP from JSON file

分類Dev

MySQL how to search a JSON field for all rows that intersect with JSON values

分類Dev

How to get values from Deserialized JSON object?

分類Dev

How to get all Object from Json to List

分類Dev

How to get Json response from server in Intent Service in android?

分類Dev

Retrofit: How to make XML request and get back JSON response

分類Dev

How to get only the relevant index values from a filtered DataFrame?

分類Dev

How to get Values of one JSON object into the Values of another with Python

分類Dev

I want to specify an array's axes and their index values and get the sub array back

Related 関連記事

  1. 1

    How to parse json to get all values of a specific key within an array?

  2. 2

    How to get all values of objects inside array

  3. 3

    How get index of array with jq

  4. 4

    RestAssured: How to check the length of json array response?

  5. 5

    How to get text values to an array?

  6. 6

    How to get all array edges?

  7. 7

    how to get valid json response from server

  8. 8

    How to get Typeahead with Bloodhound to work with a JSON response?

  9. 9

    How to get a json object with specific key values, from a json array column?

  10. 10

    How to get values in array of array in angular?

  11. 11

    In Angular 8, How to get form all values into JSON on click submit button?

  12. 12

    How to count all values in a multidimensional array?

  13. 13

    How to get all values in a string enum?

  14. 14

    how to get all values of object via coffeescript?

  15. 15

    How to get the equilibrium index of an array in O(n)?

  16. 16

    How to decode SAML Response and get the attribute values sent by Idp in PHP

  17. 17

    How to get all the headers from an Angular 2 response?

  18. 18

    How to display json array values in single UITableVIewCell

  19. 19

    how to get array values, on input field

  20. 20

    How to get the values of generic array in Java?

  21. 21

    Get index value of an array by it's value in PHP from JSON file

  22. 22

    MySQL how to search a JSON field for all rows that intersect with JSON values

  23. 23

    How to get values from Deserialized JSON object?

  24. 24

    How to get all Object from Json to List

  25. 25

    How to get Json response from server in Intent Service in android?

  26. 26

    Retrofit: How to make XML request and get back JSON response

  27. 27

    How to get only the relevant index values from a filtered DataFrame?

  28. 28

    How to get Values of one JSON object into the Values of another with Python

  29. 29

    I want to specify an array's axes and their index values and get the sub array back

ホットタグ

アーカイブ