How to store string containing nested Json object in a proper tree format
sample string:
152#233.69#-191.7#133.69#-199.769#AP#4#"{""pot"":4}"#TP#"{""Dp"":12345}" 1581#233.69#-191.7#133.69#-199.769#4#"{""pt"":4,""oil"":{""1"":""HP""}}"#UP#"{""Dp"":67890}" 16849#343.69#-291.8#133.69#-389.769#AMULL#4#"{""sport"":4,""oi"":{""1"":""LT""}}"#null#"{""Dis"":67990}"
each value is separated by # and the values maybe string representation of nested JSON objects
My code:
var myNewLine = arrayOne[i].split('#');
for (var j = 0; j < noOfCol; j++) {
var temp;
var headerText = header[j].substring(0, header[j].length);
valueText = myNewLine[j].substring(0, myNewLine[j].length);
obj[headerText] = valueText;
}
jArray.push(obj);
}
jsonObject = JSON.parse(JSON.stringify(jArray));
return jsonObject;
JSON.parse(JSON.stringify(jArray)): That's an expensive noop...