json eval giving an error - javascript

i'm using eval for the below JSON but getting syntax error :Expected ']' message. i'm not getting what i'm missing in it.
my javascript stmt is
eval('var jsonResponse = ('+response+')');
response contains the following:
{iserror:"false",employees:["employee":{"employeeNbr":"SAN1234509","emplType":"SAN","agencyNbr":"","producerNbr":"123456789","remiCode":"SA","agentRate":"SA","typeCode":"I","reasonTxt":"S3","rsnDescription":"null","ymdeff":"20130101","ymdend":"20130101","voidtxt":"V","brokerName":"429610583","brokerNpn":"429610583","ymdtrans":"null","opNbr":"null"},
"employee":{"employeeNbr":"SAN1234509","emplType":"SAN","agencyNbr":"xxxxx-C","producerNbr":"1234567890,"remiCode":"SA","agentRate":"SA","typeCode":"I","reasonTxt":"S3","rsnDescription":"null","ymdeff":"20130101","ymdend":"20130101","voidtxt":"","brokerName":"429610583","brokerNpn":"429610583","ymdtrans":"null","opNbr":"null"},
"employee":{"employeeNbr":"SAN1234509","emplType":"SAN","agencyNbr":"","producerNbr":"123456789","remiCode":"SA","agentRate":"SA","typeCode":"I","reasonTxt":"S3","rsnDescription":"null","ymdeff":"20130101","ymdend":"20130101","voidtxt":"V","brokerName":"429610583","brokerNpn":"429610583","ymdtrans":"null","opNbr":"null"}]}

For starters, you claim it's JSON, but it's not. Quotes would be required around iserror to be JSON, for example.
Specifically,
{iserror:"false",employees:[...]}
should be
{"iserror":"false","employees":[...]}
But since you actually pass the string to a JavaScript parser (eval), it merely needs to be JavaScript, not JSON. It's not valid JavaScript either, which is why you're getting the error.
You have
{
iserror:"false",
employees:[
"employee":{...},
"employee":{...},
"employee":{...}
]
}
The : after "employee" is wrong. Maybe you meant to use
{
iserror:"false",
employees:[
{...},
{...},
{...}
]
}
Also, you have
"producerNbr":"1234567890,"remiCode":"SA"
instead of
"producerNbr":"1234567890","remiCode":"SA"

Related

Printed parsed json from escaped json string but can't able to access anything from it on lambda with node 12.x

Here is the code { lambda nodejs 12.x }.
console.log("body", event.body);
var request = JSON.parse(event.body)
console.log("parsed body", request["operation"], request['"operation"'], request.operation, request);
result through log.
2021-02-16T13:54:01.357Z 78ca4692-b31d-40b2-bc32-e993a622aaa0 INFO body "{\"operation\":\"getDevice\"}
2021-02-16T13:54:01.357Z 78ca4692-b31d-40b2-bc32-e993a622aaa0 INFO parsed body undefined undefined undefined
{
"operation": "getDevice"
}
How to I access data from the object using .key or ["key"] methods
** I am checked this on browser cli it works but not on lambda I don't know what I am done wrong. Please help me.
I am solved this.
on the first time on JSON.parse returns normal json string from escaped json.
I am passed these json string to another JSON.parse it retured object.
someone check this out and report this bug.

AWS Lambda: How do I get property inside event.body, it keep return undefined

I was trying to get event.body.data, but it keep return me undefined, i tried JSON.parse(event), JSON.parse(event.body), JSON.parse(event.body.data), JSON.stringify, almost tried out things that i can do with JSON and non of them seems to work. When i tried JSON.parse(event), will give syntax error. So i suspect it already in JSON object format and when i console.log it, it didn't have the " " quote. If it is already in JSON format, why can't I access the property in it. I also tried wrap it inside if(event.body.data) and it doesn't work as well. Anyone know how to get property inside event.body?
Based on your screenshot it looks like the body data is a JSON string. That means you have to parse it first before you can use it. Something like this:
exports.handler = function(event, context, callback) {
const body = JSON.parse(event.body)
console.log('data: ', body.data)
}
Then apply the suggestions from #Marcin and fix your JSON data because it's missing quotes.
Your even.body is invalid json string, which explain why JSON.parse fails. Thus, you should check who/what is making the request and modify the code of the client side to invoke your API with a valid json string.
It should be:
'{"action": "message, "data": "black clolor"}'
not
"{action: 'message, data: 'black clolor'}"
Thanks #Marcin for the feedback, it was indeed caused by invalid json string sent from frontend.
Changing it to the code below solved the issue.
{"action": "message", "data": "black clolor"}

how to solve problem getting json object element

I have a json object that i want to use.
{
"type": "PROVIDER_PAYLOAD",
"message": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6IjVkOTQ3OTg4N2RlMGRkMDc4ZjEzM2FmNyIsImVtYWlsIjoiYWxzb25nZHVuc3RhbjJAZ21haWwuY29tIiwicm9sZSI6IkNVU1RPTUVSIiwiaWF0IjoxNTcwMDI3MDA4fQ.FcpoBPmhTSX535bNgE2ezCCWsNFPjEhc87hM4y6WadM"
}
so when i try to access it using
console.log("Postback: " + payload.type)
but i get an error of
Postback: undefined
i have looked over some resources on the web and most of them do it this way and it works but i am not sure why mine is not giving the value for type
thanks in advance
Subh is right. You have to parse the JSON into an object before accessing type using payload.type syntax.
So, let's say you have the following:
let payload = {
"type": "PROVIDER_PAYLOAD",
"message": "eyJhbGciOiJIUzWadM"
}
You have to convert it into a JS object using JSON.parse:
let payloadObj = JSON.parse(payload);
Now, if you do payloadObj.type, you should be fine.
console.log(payloadObj.type); // PROVIDER_PAYLOAD
It should work fine.
UPDATE: ERROR: SyntaxError: Unexpected token a in JSON at position 0
If you are getting this error, try following to Parse the payload.
let payloadObj = JSON.parse(JSON.stringify(payload))
It should solve the problem for you.

Calling strange field of JSON in NodeJS

im working with NodeJS and services SOAP in XML.
To call the soap I use strong-soap and to transform XML in JSON use xml2js.
All ready works good, the response shows like:
{ 'SOAP-ENV:Envelope': { '$':
{ 'xmlns:SOAP-ENV': 'http://schemas.xmlsoap.org/soap/envelope/',
'xmlns:ns1': 'http://sandbox.coordinadora.com/agw/ws/guias/1.5/server.php',
'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema',
'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns:SOAP-ENC': 'http://schemas.xmlsoap.org/soap/encoding/',
'SOAP-ENV:encodingStyle': 'http://schemas.xmlsoap.org/soap/encoding/' },
'SOAP-ENV:Body': [ [Object] ] } }
But in javascript I can call response.SOAP-ENV:Body because show me error.
What I can do to handle this data?
- and : aren't valid characters in javascript variables, so you'll have to use bracket notation like this:
let body = response['SOAP-ENV:Body']

Parse valid JSON got "SyntaxError: Unexpected token ILLEGAL"

The JSON is validated. But when I parse it with JSON.parse(), $.parseJSON() or eval(). I got
"SyntaxError: Unexpected token ILLEGAL"
Here the JSON: https://pastebin.com/cXMTw9Xu
I can parse it with php using json_decode() so I tried json_encode() then copy the result to parse in javascript. However I still got this error.
To reproduce, try to execute this script in your console on any browser.
JSON.parse('{"id":"mindmaps","options":{"id":"mindmaps","instance":"","name":"","description":"","containerStyle":{"width":"auto","height":"auto"},"viewPort":{"width":50000,"height":50000,"allowDrag":true,"left":3819,"top":4422,"originalWidth":50000,"zoom":{"w":50000,"h":50000,"l":3895,"t":4457,"r":1},"originalHeight":50000},"enabled":true,"showBirdsEye":false,"sizeOfBirdsEye":200,"showMultiSelect":false,"showZoom":false,"showStatus":false,"collaboration":{"allow":false,"showPanel":true,"useLongPolling":false,"jsonp":false,"localizedOnly":false,"userName":"","userProfile":"","userIP":"","sizeOfBirdsEye":200,"hubName":"slateHub","url":"","callbacks":{"onCollaboration":null,"onCollaborationStarted":null,"onCollaborationWired":null,"onUnauthorized":null}},"isPublic":false,"imageFolder":"http:\/\/static.slatebox.com\/cursors\/"},"nodes":[{"options":{"id":"first_node","name":"first_node","text":"\u0e02\u0e31\u0e49\u0e19\u0e15\u0e2d\u0e19\u0e01\u0e32\u0e23\u0e14\u0e33\u0e40\u0e19\u0e34\u0e19\u0e01\u0e32\u0e23\/\u0e41\u0e19\u0e27\u0e17\u0e32\u0e07","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":3635.515625,"yPos":4810,"height":74,"width":183.96875,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#ADD8C7-#59a989","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"rectangle","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"49701c9265cc","parentId":"first_node","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"e51346f8ebd7","parentId":"first_node","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"first_node","parentId":"ca6e34182a01","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"first_node","parentId":"56268f01d021","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"first_node","parentId":"8dd3e58e9e08","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"49701c9265cc","name":"first_node","text":"\t\u0e43\u0e2b\u0e49\u0e1c\u0e39\u0e49\u0e1e\u0e34\u0e01\u0e32\u0e23\u0e40\u0e1b\u0e47\u0e19\u0e04\u0e19\u0e40\u0e25\u0e37\u0e2d\u0e01 \n\u0e1e\u0e23\u0e49\u0e2d\u0e21\u0e41\u0e19\u0e1a\u0e43\u0e1a\u0e40\u0e2a\u0e19\u0e2d\u0e23\u0e32\u0e04\u0e32 \u0e41\u0e25\u0e30\u0e23\u0e39\u0e1b \n\u0e41\u0e25\u0e30\u0e21\u0e35\u0e01\u0e32\u0e23\u0e23\u0e31\u0e1a\u0e1b\u0e23\u0e30\u0e01\u0e31\u0e19\u0e44\u0e21\u0e48\u0e19\u0e49\u0e2d\u0e22\u0e01\u0e27\u0e48\u0e32 1 \u0e1b\u0e35","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4001,"yPos":4437,"height":69.21875,"width":234.59375,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}},"showParentArrow":false,"showChildArrow":false,"reattachable":true},"relationships":{"parents":[],"associations":[{"childId":"49701c9265cc","parentId":"first_node","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"e51346f8ebd7","name":"first_node","text":"\u0e43\u0e2b\u0e49\u0e1c\u0e39\u0e49\u0e1e\u0e34\u0e01\u0e32\u0e23\u0e40\u0e1b\u0e47\u0e19\u0e1c\u0e39\u0e49\u0e21\u0e32\u0e02\u0e2d\u0e40\u0e2d\u0e07 \n(\u0e22\u0e01\u0e40\u0e27\u0e49\u0e19\u0e19\u0e2d\u0e19\u0e40\u0e15\u0e35\u0e22\u0e07)","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":3999,"yPos":4514.9921875,"height":62.609375,"width":239.375,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"e51346f8ebd7","parentId":"first_node","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"e51346f8ebd7","parentId":"194a2c2bc36f","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"e51346f8ebd7","parentId":"cff7f9a59c1c","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"194a2c2bc36f","name":"first_node","text":"\t\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e14\u0e39\u0e27\u0e48\u0e32\u0e21\u0e35\u0e04\u0e27\u0e32\u0e21\u0e2d\u0e34\u0e2a\u0e23\u0e30\u0e43\u0e19\u0e01\u0e32\u0e23\u0e40\u0e25\u0e37\u0e2d\u0e01\u0e40\u0e2d\u0e07\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4298.375,"yPos":4476.9921875,"height":67.609375,"width":231.375,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"e51346f8ebd7","parentId":"194a2c2bc36f","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"cff7f9a59c1c","name":"first_node","text":"\t\u0e40\u0e1e\u0e37\u0e48\u0e2d\u0e14\u0e39\u0e27\u0e48\u0e32\u0e02\u0e2d\u0e40\u0e2d\u0e07\u0e08\u0e23\u0e34\u0e07\u0e2b\u0e23\u0e37\u0e2d\u0e44\u0e21\u0e48","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4302.75,"yPos":4546.9921875,"height":66.609375,"width":228.375,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"e51346f8ebd7","parentId":"cff7f9a59c1c","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"ca6e34182a01","name":"first_node","text":"\u0e21\u0e35\u0e19\u0e31\u0e01\u0e01\u0e32\u0e22\u0e20\u0e32\u0e1e\u0e08\u0e32\u0e01\u0e42\u0e23\u0e07\u0e1e\u0e22\u0e32\u0e1a\u0e32\u0e25\u0e1e\u0e23\u0e30\u0e21\u0e07\u0e01\u0e38\u0e0e \n\u0e0a\u0e48\u0e27\u0e22\u0e27\u0e34\u0e40\u0e04\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e04\u0e27\u0e32\u0e21\u0e40\u0e2b\u0e21\u0e32\u0e30\u0e2a\u0e21","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4002.46875,"yPos":4657.5,"height":61,"width":245.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"first_node","parentId":"ca6e34182a01","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"ca6e34182a01","parentId":"ca514c19c067","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"ca6e34182a01","parentId":"9df922474ff8","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"ca514c19c067","name":"first_node","text":"\t\u0e27\u0e34\u0e40\u0e04\u0e23\u0e32\u0e30\u0e2b\u0e4c\u0e2a\u0e20\u0e32\u0e1e\u0e04\u0e27\u0e32\u0e21\u0e1e\u0e34\u0e01\u0e32\u0e23","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4303.5,"yPos":4617.5,"height":62,"width":238.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"ca6e34182a01","parentId":"ca514c19c067","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"9df922474ff8","name":"first_node","text":"\t\u0e14\u0e39\u0e04\u0e27\u0e32\u0e21\u0e40\u0e2b\u0e21\u0e32\u0e30\u0e2a\u0e21\u0e02\u0e2d\u0e07\u0e2d\u0e38\u0e1b\u0e01\u0e23\u0e13\u0e4c\u0e17\u0e35\u0e48\u0e04\u0e27\u0e23\u0e43\u0e0a\u0e49","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4308.53125,"yPos":4694.5,"height":65,"width":242.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"ca6e34182a01","parentId":"9df922474ff8","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"56268f01d021","name":"first_node","text":"\u0e04\u0e13\u0e30\u0e01\u0e23\u0e23\u0e21\u0e01\u0e32\u0e23","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4013.5625,"yPos":4911.5,"height":64,"width":238.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"first_node","parentId":"56268f01d021","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"56268f01d021","parentId":"50e87752c77e","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"56268f01d021","parentId":"1af5c25a2616","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"56268f01d021","parentId":"26e6b42303bd","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"56268f01d021","parentId":"616e1d6aba5a","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"50e87752c77e","name":"first_node","text":"\t\u0e08\u0e30\u0e1e\u0e34\u0e08\u0e32\u0e23\u0e13\u0e32\u0e40\u0e1e\u0e14\u0e32\u0e19\u0e23\u0e32\u0e04\u0e32\u0e43\u0e19\u0e15\u0e25\u0e32\u0e14 \n\u0e1b\u0e31\u0e08\u0e08\u0e38\u0e1a\u0e31\u0e19\u0e21\u0e35\u0e01\u0e32\u0e23\u0e15\u0e31\u0e49\u0e07\u0e23\u0e32\u0e04\u0e32\u0e01\u0e25\u0e32\u0e07","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4313.375,"yPos":4766.5,"height":67,"width":244.4375,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"56268f01d021","parentId":"50e87752c77e","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"1af5c25a2616","name":"first_node","text":"\t\u0e41\u0e1a\u0e48\u0e07\u0e40\u0e1b\u0e47\u0e19 2 \u0e01\u0e25\u0e38\u0e48\u0e21","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4311.40625,"yPos":4838.5,"height":67,"width":239.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"56268f01d021","parentId":"1af5c25a2616","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"1af5c25a2616","parentId":"189e023daafc","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"1af5c25a2616","parentId":"c6d478066d47","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"189e023daafc","name":"first_node","text":"\u0e01\u0e25\u0e38\u0e48\u0e21\u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e21\u0e35\u0e1b\u0e31\u0e0d\u0e2b\u0e32 \u0e0a\u0e31\u0e14\u0e40\u0e08\u0e19","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4574.4375,"yPos":4786.5,"height":72,"width":190.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"1af5c25a2616","parentId":"189e023daafc","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"c6d478066d47","name":"first_node","text":"\u0e01\u0e25\u0e38\u0e48\u0e21\u0e17\u0e35\u0e48\u0e15\u0e49\u0e2d\u0e07\u0e21\u0e35\u0e01\u0e32\u0e23\u0e1e\u0e34\u0e08\u0e32\u0e23\u0e13\u0e32","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4572.46875,"yPos":4898.5,"height":76,"width":181.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"1af5c25a2616","parentId":"c6d478066d47","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"c6d478066d47","parentId":"cd0f3786b7fe","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"c6d478066d47","parentId":"fedcba0e0c21","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"cd0f3786b7fe","name":"first_node","text":"\u0e01\u0e25\u0e38\u0e48\u0e21\u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e21\u0e35\u0e04\u0e27\u0e32\u0e21\u0e0a\u0e31\u0e14\u0e40\u0e08\u0e19\n\u0e43\u0e19\u0e25\u0e31\u0e01\u0e29\u0e13\u0e30\u0e04\u0e27\u0e32\u0e21\u0e1e\u0e34\u0e01\u0e32\u0e23","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4819.5,"yPos":4847.5,"height":78,"width":201.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"c6d478066d47","parentId":"cd0f3786b7fe","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"fedcba0e0c21","name":"first_node","text":"\t\u0e01\u0e25\u0e38\u0e48\u0e21\u0e17\u0e35\u0e48\u0e44\u0e21\u0e48\u0e40\u0e2b\u0e21\u0e32\u0e30\u0e2a\u0e21\u0e02\u0e2d\u0e07\u0e2d\u0e38\u0e1b\u0e01\u0e23\u0e13\u0e4c","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4817.53125,"yPos":4953.5,"height":82,"width":196.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"c6d478066d47","parentId":"fedcba0e0c21","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"26e6b42303bd","name":"first_node","text":"\t\u0e40\u0e01\u0e13\u0e11\u0e4c\u0e01\u0e32\u0e23\u0e43\u0e2b\u0e49\u0e04\u0e30\u0e41\u0e19\u0e19","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4310.59375,"yPos":5041.5,"height":64,"width":238.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"56268f01d021","parentId":"26e6b42303bd","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"26e6b42303bd","parentId":"fe305f32d96a","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false},{"childId":"26e6b42303bd","parentId":"c7d3cbe98b17","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"fe305f32d96a","name":"first_node","text":"\u0e17\u0e33\u0e2d\u0e22\u0e48\u0e32\u0e07\u0e44\u0e23\u0e44\u0e21\u0e48\u0e43\u0e2b\u0e49\u0e15\u0e49\u0e2d\u0e07\u0e1e\u0e36\u0e48\u0e07\u0e04\u0e27\u0e32\u0e21\u0e23\u0e39\u0e49\u0e2a\u0e36\u0e01 \n(\u0e2d\u0e30\u0e44\u0e23\u0e17\u0e35\u0e48\u0e1c\u0e25\u0e15\u0e48\u0e2d\u0e04\u0e27\u0e32\u0e21\u0e1e\u0e34\u0e01\u0e32\u0e23 \u0e17\u0e35\u0e48\u0e08\u0e33\u0e40\u0e1b\u0e47\u0e19\u0e15\u0e49\u0e2d\u0e07\u0e21\u0e35\u0e2d\u0e38\u0e1b\u0e01\u0e23\u0e13\u0e4c)","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4601.75,"yPos":5000.5,"height":78,"width":260.625,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"26e6b42303bd","parentId":"fe305f32d96a","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"c7d3cbe98b17","name":"first_node","text":"\u0e40\u0e23\u0e34\u0e48\u0e21\u0e2a\u0e48\u0e07\u0e43\u0e2b\u0e49\u0e15\u0e48\u0e32\u0e07\u0e08\u0e31\u0e07\u0e2b\u0e27\u0e31\u0e14\u0e43\u0e0a\u0e49\u0e40\u0e01\u0e13\u0e11\u0e4c\u0e19\u0e35\u0e49\n\u0e43\u0e19\u0e01\u0e32\u0e23\u0e1e\u0e34\u0e08\u0e32\u0e23\u0e13\u0e32\u0e40\u0e2d\u0e07\u0e41\u0e25\u0e49\u0e27 (\u0e43\u0e19\u0e2d\u0e14\u0e35\u0e15\u0e1e\u0e36\u0e48\u0e07\u0e2a\u0e48\u0e27\u0e19\u0e01\u0e25\u0e32\u0e07)","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4603.75,"yPos":5087.5,"height":77,"width":264.0625,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"26e6b42303bd","parentId":"c7d3cbe98b17","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"616e1d6aba5a","name":"first_node","text":"\u0e2d\u0e19\u0e38\u0e21\u0e31\u0e15\u0e34","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4305.59375,"yPos":5129.5,"height":64,"width":238.03125,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"56268f01d021","parentId":"616e1d6aba5a","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}},{"options":{"id":"8dd3e58e9e08","name":"first_node","text":"-\t\u0e15\u0e2d\u0e19\u0e08\u0e48\u0e32\u0e22\u0e40\u0e07\u0e34\u0e19 \u0e08\u0e30\u0e43\u0e2b\u0e49\u0e1e\u0e1a\u0e01\u0e31\u0e19 3 \u0e1d\u0e48\u0e32\u0e22 \n\u0e44\u0e14\u0e49\u0e41\u0e01\u0e48 \u0e01\u0e23\u0e21\u0e2f \u0e1c\u0e39\u0e49\u0e1e\u0e34\u0e01\u0e32\u0e23 \u0e41\u0e25\u0e30\u0e1c\u0e39\u0e49\u0e08\u0e33\u0e2b\u0e19\u0e48\u0e32\u0e22","isPinned":false,"isPinnedExact":false,"pinnedRowCount":5,"image":"","imageTiled":false,"xPos":4020.921875,"yPos":5126.5,"height":86,"width":244.40625,"borderWidth":2,"lineColor":"red","lineWidth":2,"lineOpacity":1,"allowDrag":true,"allowMenu":true,"allowContext":true,"backgroundColor":"90-#1693A5-#23aad6","foregroundColor":"#000","fontSize":13,"fontFamily":"Trebuchet MS","fontStyle":"normal","vectorPath":"ellipse","rotationAngle":0,"link":{"show":false,"type":"","data":"","thumbnail":{"width":175,"height":175}}},"relationships":{"parents":[],"associations":[{"childId":"first_node","parentId":"8dd3e58e9e08","isStraightLine":false,"lineColor":"red","lineOpacity":1,"lineWidth":2,"showParentArrow":false,"showChildArrow":false}]}}]}');
Solved
I just found out that if I ajax this JSON using below script. It work like a charm.
But why it does not work with JSON.parse() is still unknown.
$.ajax({
dataType: 'JSON',
method: 'GET',
url: 'path/to/mindmaps.json'
}).success(function(result)){
console.log(result);
}
You are doing everything correctly, you are just missing 1 piece:
JSON.parse and $.parseJSON are expecting strings, not objects. If you were to throw that giant glob into either function, they won't work (you get the stack trace that you see right now.)
If instead, you do the following...
var copyPasteJson = /* your json here */ ;
var parsedResult = JSON.parse(JSON.stringify(copyPasteJson));
Full example here: http://jsfiddle.net/xhx47ghg/
With all that said... you don't need to go through the trouble of converting the copyPasteJson to a string and back to json, you can simply use the object literal, copyPasteJson.

Categories