Click here to Skip to main content
15,886,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
I want to JSON.parse the below data

data=["{\"ID\":29614,\"Ratio\":8,\"UOM\":\"IN\",\"manufacturers\":{\"manufacturerName\":\"john\",\"categories\":{\"categoryName\":\"Beverage\",\"products\":{\"uid\":\"456\",\"productID\":140721,\"name\":\"After Shocks Popping Candy 1.06\"}}},{\"manufacturerName\":\"john\",\"categories\":{\"categoryName\":\"Beverage\",\"products\":{\"uid\":\"456\",\"productID\":140721,\"name\":\"After Shocks Popping Candy 1.06\"}}}}"]

What I have tried:

JSON.parse(dataString); //getting ERROR SyntaxError: Unexpected token { in JSON at position 1518
Posted
Updated 3-Jan-20 2:12am
Comments
Richard MacCutchan 3-Jan-20 7:24am    
And? What is stopping you?

1 solution

hello,
"manufacturers" should be array like this

"manufacturers": [
			{
				"manufacturerName": "john",
				"categories": {
					"categoryName": "Beverage",
					"products": {
						"uid": "456",
						"productID": 140721,
						"name": "After Shocks Popping Candy 1.06"
					}
				}
			},
			{
				"manufacturerName": "john",
				"categories": {
					"categoryName": "Beverage",
					"products": {
						"uid": "456",
						"productID": 140721,
						"name": "After Shocks Popping Candy 1.06"
					}
				}
			}
		]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900