Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does '@' mean in JSON?

I'm using the following library

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

To convert XML to JSON. After conversion console.log produces 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 assuming the data is stored in a variable named 'result' what is the syntax for accessing RaceDayDate, Year, Month etc? result.@ does not work

like image 901
Hoa Avatar asked Dec 16 '22 02:12

Hoa


1 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 is missing quotes around many dictionary keys and Object, uses single instead of double quotes and ends with a comma.

like image 200
phihag Avatar answered Jan 04 '23 20:01

phihag