Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parsing JSON w/ @ at sign symbol in it (arobase)

Tags:

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

like image 934
user823596 Avatar asked Aug 03 '11 20:08

user823596


People also ask

What does AT symbol mean in JSON?

5. Quite an old question but it comes up in Google searches. The @ symbol in JSON is JSON-LD (JSON for Linked Data).

What is JSON parse () method?

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.

What is parsing explain JSON parsing with example?

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.


1 Answers

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]; 
like image 168
JAAulde Avatar answered Sep 19 '22 15:09

JAAulde