Possible Duplicate:
How to extract specific data from JSON using CoffeeScript?
I want to grab a specific piece of data from a massive JSON string. The entire string would be more than 10 pages long if posted here, so I'm just including an example snippet:
{ name: '',
keys:
[ 'statType',
'count',
'dataVersion',
'value',
'championId',
'futureData' ],
object:
{ statType: 'TOTAL_SESSIONS_PLAYED',
count: { value: 5 },
dataVersion: 0,
value: { value: 5 },
championId: { value: 31 },
futureData: null },
encoding: 0 }
How can I use CoffeeScript to:
- parse that string to locate the object with a specific value, such as
TOTAL_SESSIONS_PLAYED
, - take the numerical value from that object (the
value
field), and - ideally, append that value into an external text file?
I am pretty much a super noob programmer. Basically, how could I, in this example, take that 5
value from the object labelled TOTAL_SESSIONS_PLAYED
, and append it into a text file using CoffeeScript?