My JSON object evaluates to:
{ "@io": IO, "@type": XXX }
If this variable is called my_json
, how do I access the @type
value of XXX? I tried my_json.@type
, but this is giving errors. Help appreciated. Thanks,
Nick
5. Quite an old question but it comes up in Google searches. The @ symbol in JSON is JSON-LD (JSON for Linked Data).
parse() The JSON. parse() method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.
JSON - Parsing For parsing a JSON object, we will create an object of class JSONObject and specify a string containing JSON data to it. Its syntax is − String in; JSONObject reader = new JSONObject(in); The last step is to parse the JSON.
Use square bracket notation with a string:
var XXXValue = my_json['@type'];
The same can be used when you have a property name in a variable. Using your same example:
var propertyName = '@type'; var XXXValue = my_json[propertyName];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With