JSON Dataset
JSON Dataset
What's the simplest way to take a JSON response and convert it to a data set that Switch can use?
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
JSON Dataset
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
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.
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.
Chat: open-automation @ gitter
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
Code: open-automation & dominickp @ GitHub
Tools: Switch, Pitstop, EPMS, Veracore, PageDNA, SmartStream, Metrix
-
- TOP CONTRIBUTOR
- Posts: 628
- Joined: Mon Nov 29, 2010 8:45 pm
- Location: Alpharetta GA USA
- Contact:
JSON Dataset
There are many Javascript JSON2XML converters that should work with small modifications to remove unsupported Javascript language features such as 'object.constructor'.