arihan
11-23-2012, 12:34 PM
Hi,
I am facing the problem while converting json to xml through vbscript using Newtonsoft.Json.dll.
It works fine if there is single json . However its not working for multiple jsons. I've already given the sample json below and also snippet of code.
Any thoughts??????
say
============================================================
responsivePuffsContentInJson=Getxmlnodetext(XMLDoc,"/section/responsive-puffs/content")
lib =Parameter("curr_directory")&"\jsonassembly\Bin\Net35\Newtonsoft.Json.dll"
Set JsonConvert = DOTNetFactory.CreateInstance("Newtonsoft.Json.JsonConvert", lib)
json = "{ ""?xml"": { ""@version"": ""1.0"", ""@standalone"": ""no"" }, ""root"":" &responsivePuffsContentInJson& "}"
Set xmlDoc = JsonConvert.DeserializeXmlNode(json)
Dim xmlDocc,convcontent
Set xmlDocc = CreateObject("Msxml2.DOMDocument")
xmlDocc.async = False
convcontent=xmlDoc.InnerXml
msgbox "convcontent"&convcontent
xmlDocc.loadXML(convcontent )
=======================================
working fine for json
[
{
"id": "47638",
"sectionColour": "#0a5f00",
"headline": "arihan new puff 20th nov",
"author": "ariahn test author",
"teaser": "test ",
"components": {},
"publishDate": "2012-11-20T17:49:15Z",
"idLink": "6313_6316_122_47594",
"puffType": "times_cutOut"
}
]
doesnot work for below json
[
{
"id": "41942",
"sectionColour": "#8c8c3f",
"headline": "F1 Puff",
"author": "Bob James",
"teaser": "For all the latest Formula One News",
"components": {
"images": [
{
"url": "http://tablet-si.cloud-newsint.co.uk/times/incoming/article48913.ece/BINARY/10inch_p/CAROL_MIDGLEY.png",
"width": 300,
"height": 499,
"crop": true,
"mandatory": false,
"deviceType": "images",
"addToCarousel": false,
"disableTap": false
}
]
},
"publishDate": "2012-11-05T11:53:42Z",
"idLink": "7019_7022_122_41430"
},
{
"id": "47953",
"sectionColour": "#8c8c3f",
"headline": "arihan test puff 21st nov -1 headline",
"author": "test",
"teaser": "test",
"publishDate": "2012-11-21T11:24:53Z",
"webLink": "http://www.google.com",
"puffType": "times_cutOut"
},
{
"id": "48905",
"sectionColour": "#8c8c3f",
"headline": "Puff Headline09:45:42",
"author": "SmokeTest Automation Author",
"teaser": "SmokeTest Automation Teaser",
"publishDate": "2012-11-22T09:45:44Z",
"puffType": "times_cutOut"
}
]
I am facing the problem while converting json to xml through vbscript using Newtonsoft.Json.dll.
It works fine if there is single json . However its not working for multiple jsons. I've already given the sample json below and also snippet of code.
Any thoughts??????
say
============================================================
responsivePuffsContentInJson=Getxmlnodetext(XMLDoc,"/section/responsive-puffs/content")
lib =Parameter("curr_directory")&"\jsonassembly\Bin\Net35\Newtonsoft.Json.dll"
Set JsonConvert = DOTNetFactory.CreateInstance("Newtonsoft.Json.JsonConvert", lib)
json = "{ ""?xml"": { ""@version"": ""1.0"", ""@standalone"": ""no"" }, ""root"":" &responsivePuffsContentInJson& "}"
Set xmlDoc = JsonConvert.DeserializeXmlNode(json)
Dim xmlDocc,convcontent
Set xmlDocc = CreateObject("Msxml2.DOMDocument")
xmlDocc.async = False
convcontent=xmlDoc.InnerXml
msgbox "convcontent"&convcontent
xmlDocc.loadXML(convcontent )
=======================================
working fine for json
[
{
"id": "47638",
"sectionColour": "#0a5f00",
"headline": "arihan new puff 20th nov",
"author": "ariahn test author",
"teaser": "test ",
"components": {},
"publishDate": "2012-11-20T17:49:15Z",
"idLink": "6313_6316_122_47594",
"puffType": "times_cutOut"
}
]
doesnot work for below json
[
{
"id": "41942",
"sectionColour": "#8c8c3f",
"headline": "F1 Puff",
"author": "Bob James",
"teaser": "For all the latest Formula One News",
"components": {
"images": [
{
"url": "http://tablet-si.cloud-newsint.co.uk/times/incoming/article48913.ece/BINARY/10inch_p/CAROL_MIDGLEY.png",
"width": 300,
"height": 499,
"crop": true,
"mandatory": false,
"deviceType": "images",
"addToCarousel": false,
"disableTap": false
}
]
},
"publishDate": "2012-11-05T11:53:42Z",
"idLink": "7019_7022_122_41430"
},
{
"id": "47953",
"sectionColour": "#8c8c3f",
"headline": "arihan test puff 21st nov -1 headline",
"author": "test",
"teaser": "test",
"publishDate": "2012-11-21T11:24:53Z",
"webLink": "http://www.google.com",
"puffType": "times_cutOut"
},
{
"id": "48905",
"sectionColour": "#8c8c3f",
"headline": "Puff Headline09:45:42",
"author": "SmokeTest Automation Author",
"teaser": "SmokeTest Automation Teaser",
"publishDate": "2012-11-22T09:45:44Z",
"puffType": "times_cutOut"
}
]