What does "@" mean in JSON?

I am using the following library

https://github.com/Leonidas-from-XIV/node-xml2js

Converting XML to JSON. After conversion, console.log creates the following

{ '@':
   { RaceDayDate: '2012-03-15T00:00:00',
     Year: '2012',
     Month: '3',
     Day: '15',
     DayOfTheWeek: 'Thursday',
     MonthLong: 'March',
     IsCurrentDay: '1',
     IsPresaleMeeting: '0',
     ServerTime: '2012-03-15T19:48:47.840' },
  PresaleRaceDate: [ { '@': [Object] }, { '@': [Object] }, { '@': [Object] } ],
  Meeting:
   [ { '@': [Object], Pool: [Object], Race: [Object] },
     { '@': [Object], Pool: [Object], Race: [Object] },
     { '@': [Object], Pool: [Object], Race: [Object] },

      

What does @ mean and the data is supposed to be stored in a variable named "result", what is the syntax for accessing RaceDayDate, year, month, etc.? result. @does not work

+3


source to share


4 answers


'@'

is just a string like any other. In JavaScript, you can access it with

result['@']

      



Also note that the input is not valid JSON as it skips quotes in many dictionary keys and Object

uses single quotes instead of double quotes and ends with a comma.

+10


source


try it result['@'].RaceDayDate

.



+1


source


It doesn't really matter for JSON.

This particular data uses it as a key string. You have to know the meaning of the data to find out why.

0


source


I'm not sure if this applies to this example, but I am currently integrating with an API that allows xml or json to be passed; in json messages, any field that is stored as an attribute in the xml version of this message is prefixed with the "@" symbol. I guess this is because the json is converted to xml for processing and whatever tool they use to do this is using @ to distinguish between elements and attributes.

0


source







All Articles