How do I access a JSON in Dreamfactory? [V8JS]


#1

I am calling a JSON from a CRM API and is returned looking like this:


{“response”:
{“result”:
{“Contacts”:
{“row”:
{“no”:“1”,
“FL”:
[
{“val”:“Name”,“content”:“Billy”},
{“val”:“Age”,“content”:“17”},
]
}
}
},
“uri”:"/crm/private/json/Contacts/getRecordById"
}
}


However I cannot seem to access it in the manner that I find online and I was wondering if there was a specific method that was used by Dreamfactory.


#2

Hey,

try something like

var apiresponse = {"response":
{"result":
{"Contacts":
{"row":
{"no":"1",
"FL":
[
{"val":"Name","content":"Billy"}, 
{"val":"Age","content":"17"},
]
}
}
}, 
"uri":"/crm/private/json/Contacts/getRecordById"
}
}

//stringify it at first
var jsonstring = JSON.stringify(apiresponse);

//then parse the jsonstring
var jsonparsed = JSON.parse(jsonstring);


#3

Thank you for the help. I tried this and it still doesn’t work.

I have now gotten around the issue by flattening the JSON.