AnsweredAssumed Answered

JSON Parser

Question asked by Harish Gupta on Feb 21, 2019
Latest reply on Feb 25, 2019 by Mark Price

Hi,

 

I am sending a Json file using Post request to Marketo. Here is the JSON:

 

{

 

 

"action":"createOrUpdate",

 

"lookupField":"email",

 

"input":[

 

 

{

"requestedCampaignType":"orderConfirmation",

"totalProductPurchased":"2",

"shippingAddress":"48 B",

"shippingCity":"Jammu",

"shippingState":"Jammu and Kashmir",

"shippingCountry":"India",

 

 

"sampleJson" : [

{

  "ProductID" : "1",

  "ProductName" : "Mi Mix 2 (Black, 128 GB)",

  "ProductPrice" : "$ 299.98",

  "Quantity" : "1",

  "ProductColor":"Midnight Black"

},

{

  "ProductID" : "2",

  "ProductName" : "Mi Mix 3 (Black, 256 GB)",

  "ProductPrice" : "$ 399.98",

  "Quantity" : "1",

  "ProductColor":"Midnight Black"

}

]

}

]

}

 

 

The field "sampleJson" is a textarea type field. When i am checking this data in Marketo under "sampleJson" file, it's coming like:

 

[{

ProductID=1, ProductName=AC (Black, 128 GB), Product Price=$ 599.98, Quantity=1, ProductColor=Midnight Dark}, {ProductID=2, ProductName=Cooler (Black, 256 GB), Product Price=$ 399.98, Quantity=1, ProductColor=Dark Black

}]

 

Can anyone  help me with the reason why Marketo is changing the format of nested json and what is the correct way to keep the format similar in Marketo like I am sending in my post  request.

 

Also, my Velocity script is successfully parsing the JSON when i am storing it like:

[

{

  "ProductID" : "1",

  "ProductName" : "Mi LED",

  "ProductPrice" : "$ 299.98",

  "Quantity" : "1",

  "ProductColor":"Dark Black"

},

{

  "ProductID" : "2",

  "ProductName" : "LG Cooler",

  "ProductPrice" : "$ 399.98",

  "Quantity" : "1",

  "ProductColor":"Dark Red"

}

]

 

but If I run my Velocity script on the format which Marketo is changing then Marketo is showing the error and script is not running.

 

Please suggest.Sanford Whiteman

Outcomes