Page 1 of 1

JSON Dataset

Posted: Tue Dec 23, 2014 4:54 am
by gabrielp
What's the simplest way to take a JSON response and convert it to a data set that Switch can use?

JSON Dataset

Posted: Tue Dec 23, 2014 3:45 pm
by dkelly




var jsonString = '{

"glossary": {

"title": "example glossary",

"GlossDiv": {

"title": "S",

"GlossList": {

"GlossEntry": {

"ID": "SGML",

"SortAs": "SGML",

"GlossTerm": "Standard Generalized Markup Language",

"Acronym": "SGML",

"Abbrev": "ISO 8879:1986",

"GlossDef": {

"para": "A meta-markup language, used to create markup languages such as DocBook.",

"GlossSeeAlso": ["GML", XML]

},

"GlossSee": "markup"

}

}

}

}

}';



var parsedObject = eval("(" + jsonString + ")");

s.log(2, parsedObject.glossary.title);

JSON Dataset

Posted: Tue Dec 23, 2014 3:56 pm
by gabrielp
Sorry Dwight, I think I was unclear. Yours is a little more concise but I have been doing something similar:



var objJSON = eval("(function(){return " + JSONString + ";})()");



What I'm after is trying to take a big JSON object and easily get it into Switch metadata somehow. Right now, I have to do something like you suggested and above and write each key to Private Data. I'm wondering how you could take a big, complex, JSON object and put it into a Switch dataset somehow so you could reference all of the values in the flow later.

JSON Dataset

Posted: Tue Dec 23, 2014 6:45 pm
by dkelly
There are many Javascript JSON2XML converters that should work with small modifications to remove unsupported Javascript language features such as 'object.constructor'.