multidimension json array
Hi there, I have a multidimension array:
- {
- "errorCode": 200,
- "errorMsg": null,
- "obj": [
- {
- "comparableInfo": null,
- "id": 1,
- "name": {
- "comparableInfo": null,
- "val": "EUROPA",
- "id": 0,
- "description": null,
- "traslation": {
- "EN": {
- "comparableInfo": null,
- "lang": null,
- "val": "EUROPE"
- },
- "IT": {
- "comparableInfo": null,
- "lang": null,
- "val": "EUROPA"
- }
- }
- },
- "img": {
- "comparableInfo": null,
- "id": 0,
- "name": "",
- "url": null,
- "file": null,
- "contentType": null,
- "comments": null,
- "owner": null,
- "likes": null,
- "tags": null,
- "is": null,
- "numberOfLike": 0
- }
- },
- {
- "comparableInfo": null,
- "id": 2,
- "name": {
- "comparableInfo": null,
- "val": "ASIA",
- "id": 0,
- "description": null,
- "traslation": {
- "EN": {
- "comparableInfo": null,
- "lang": null,
- "val": "ASIA"
- },
- "IT": {
- "comparableInfo": null,
- "lang": null,
- "val": "ASIA"
- }
- }
- },
- "img": {
- "comparableInfo": null,
- "id": 0,
- "name": "",
- "url": null,
- "file": null,
- "contentType": null,
- "comments": null,
- "owner": null,
- "likes": null,
- "tags": null,
- "is": null,
- "numberOfLike": 0
- }
- },
- {
- "comparableInfo": null,
- "id": 3,
- "name": {
- "comparableInfo": null,
- "val": "AFRICA",
- "id": 0,
- "description": null,
- "traslation": {
- "EN": {
- "comparableInfo": null,
- "lang": null,
- "val": "AFRICA"
- },
- "IT": {
- "comparableInfo": null,
- "lang": null,
- "val": "AFRICA"
- }
- }
- },
- "img": {
- "comparableInfo": null,
- "id": 0,
- "name": "",
- "url": null,
- "file": null,
- "contentType": null,
- "comments": null,
- "owner": null,
- "likes": null,
- "tags": null,
- "is": null,
- "numberOfLike": 0
- }
- },
- {
- "comparableInfo": null,
- "id": 4,
- "name": {
- "comparableInfo": null,
- "val": "AMERICA",
- "id": 0,
- "description": null,
- "traslation": {
- "EN": {
- "comparableInfo": null,
- "lang": null,
- "val": "AMERICA"
- },
- "IT": {
- "comparableInfo": null,
- "lang": null,
- "val": "AMERICA"
- }
- }
- },
- "img": {
- "comparableInfo": null,
- "id": 0,
- "name": "",
- "url": null,
- "file": null,
- "contentType": null,
- "comments": null,
- "owner": null,
- "likes": null,
- "tags": null,
- "is": null,
- "numberOfLike": 0
- }
- },
- {
- "comparableInfo": null,
- "id": 5,
- "name": {
- "comparableInfo": null,
- "val": "OCEANIA",
- "id": 0,
- "description": null,
- "traslation": {
- "EN": {
- "comparableInfo": null,
- "lang": null,
- "val": "OCEANIA"
- },
- "IT": {
- "comparableInfo": null,
- "lang": null,
- "val": "OCEANIA"
- }
- }
- },
- "img": {
- "comparableInfo": null,
- "id": 0,
- "name": "",
- "url": null,
- "file": null,
- "contentType": null,
- "comments": null,
- "owner": null,
- "likes": null,
- "tags": null,
- "is": null,
- "numberOfLike": 0
- }
- }
- ]
- }
I need have this data id, name:value from it
I try write some code but I can't understand how parse the sub array like name.
this is my primitive code:
- $(function(){
-
- var data;
- var l_id_nation;
- var name;
-
- $.ajax({
-
- type: 'GET',
- dataType:'json',
- url:'json.php',
-
- success: function(response) {
-
- data = response.obj;
-
- console.log(data);
- $.each(data, function(i, id_nation){
-
- l_id_nation = id_nation.id;
-
-
- $('#sidemenu').append('<li>'+l_id_nation+'</li>');
-
- });
-
- },
- error: function(xhr, ajaxOptions, thrownError) {
- alert(xhr.status);
- alert(thrownError);
- }
- });
-
});
my target is have the id and the name of continet for it
so I can write
- $('#sidemenu').append('<li><a href=url/'+id+'>'+name+'</a></li>');