I'm trying to figure out how to access the value inside two dictionaries via JavaScript.
The JSON output from the server is;
{"meta":{},"linked":{custom_fields":[{"id":"4","name":"Department"}],"custom_field_values":[{"id":"0001","value":"Marketing","links":{"custom_field":{"id":"4","type":"custom_fields"}}}]
I need to list Marketing as the department. I can't seem to access "links" to pull the id.
If I create var linked = linked.custom_field_values;
I get a response.
{"id":"0001","value":"Marketing","links":{"custom_field":{"id":"4","type":"custom_fields"}}}
As soon as I try to var cfl = linked.links.custom_field.id
it's saying links isn't defined. So I'm not sure what I'm doing wrong in trying to create a variable for this?
Links is a dict with Custom_field right under as a dict with the values I need.
Wouldn't this print out the department correctly if everything works right?
if(cfl.id == 4){
console.log('Department is ' + linked.value);
}