I have one json string like below
[
{
\"Name\": \"TEST\",
\"deviceId\": \"\",
\"CartId\": \"\",
\"timestamp\": 138319726
var tmpStr = '[
{
"Name": "TEST",
"deviceId": "",
"CartId": "",
"timestamp": 1383197265540,
"FOOD": [],
"City": "LONDON CA"
}
]';
var newStr = tmpStr.substring(1, tmpStr.length-1);
See this codepen example
Use this when you return:
return properties[0];
Or
var data = [
{
"Name": "TEST",
"deviceId": "",
"CartId": "",
"timestamp": 1383197265540,
"FOOD": [],
"City": "LONDON CA"
}
]; // Or whatever the Json is
data = data[0];
Or if you're accessing the json via another object
var data = jsonObj[0];
Try This:
var A = [{}]; var B = {}; A = [
{
"Name": "TEST",
"deviceId": "",
"CartId": "",
"timestamp": 1383197265540,
"FOOD": [],
"City": "LONDON CA"
}
]
B = A[0]; console.log(B); //required output