Hi Experts ,
Am trying to serailize a dynamic object to array . but its not working correctly and here is my code
dynamic product = new JObject();
foreach (PropertyImage tbl in LST)
{
product.FullImage = SiteUrl + "/" + tbl.Photo;
product.imageThumb = SiteUrl + "/" + tbl.Photo;
product.description = tbl.Tag;
product.Address = Address;
product.imageid = tbl.OrderNumber;
product.TextColor = "White";
if (Photos != "")
{
Photos += "," + product.ToString();
}
else
{
Photos += product.ToString();
}
}
//Json += Photos;
// Json += "]";
var json = JsonConvert.SerializeObject(Photos, Formatting.Indented); ;
Select all Open in new window
but am getting json output as
"{\r\n \"FullImage\": \"http://localhost:57226/img/image1.JPG\",\r\n \"imageThumb\": \"http://localhost
:57226/img/image1.JPG\",\r\n \"description\": \"Kitchen\",\r\n \"Address\": \"Test\",\r\n \"imageid
\": 1,\r\n \"TextColor\": \"White\"\r\n},{\r\n \"FullImage\": \"http://localhost:57226/img/image1.JPG
\",\r\n \"imageThumb\": \"http://localhost:57226/img/image1.JPG\",\r\n \"description\": \"Bedroom\"
,\r\n \"Address\": \"Test\",\r\n \"imageid\": 1,\r\n \"TextColor\": \"White\"\r\n}"
Select all Open in new window
[
{
"FullImage": "http://localhost:57226/img/image1.JPG",
"imageThumb": "http://localhost:57226/img/image1.JPG",
"description": "http://localhost:57226/img/image1.JPG",
"Address": "Test",
"imageid": "1",
"TextColor": "White"
},
{
"FullImage": "http://localhost:57226/img/image1.JPG",
"imageThumb": "http://localhost:57226/img/image1.JPG",
"description": "http://localhost:57226/img/image1.JPG",
"Address": "Test",
"imageid": "1",
"TextColor": "White"
}
]
. but now js throws error as SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data . Any idea on this