a = JSON.parse('["<input class="image" type="file" name="%simg_%d"/>"]');
gives the above error. Can someone explain why? Is %s the start of some kind of special character string in json/javascript?
You don't escape the quotes so you keep breaking in and out of the string which makes for invalid JSON
JSON.parse('["<input class=\\"image\\" type=\\"file\\" name=\\"%simg_%d\\"/>"]');
Related
I am trying to assign the value to variable in simple Java Script but getting "unexpected identifier" error, I feel that the% signs are creating problem here.
Any suggestion please?
You need to surround strings with quotes (' or ")
the value you are assigning to the rid is string.
So, always use Quotes
'or"
So I am trying to export a three.js scene using the SceneExporter, I am just doing this
var output = new THREE.SceneExporter().parse(scope.renderingEngine.scene);
When doing this, I get an error
Uncaught SyntaxError: Unexpected token u
Which occurs at line 750 of SceneExporter.js (which is the line where the JSON gets parsed; new THREE.SceneExporter().parse(scope.renderingEngine.scene);)
I don't have anything fancy going on in the scene, just a bunch of geometries. I even tried a scene with no textures in it and still got this error.
Now, if I change that line to simply return the output then JSON.stringify(output) and save this file, the file's JSON does not validate. I get the following error
Parse error on line 1:
"{ \n\t\"metadat
^
Expecting '{', '['
And here is line 1-10 of the JSON file
"{
\n\t\"metadata\": {
\n\t\t\"formatVersion\": 3.2,
\n\t\t\"type\"\t\t: \"scene\",
\n\t\t\"generatedBy\"\t: \"SceneExporter\",
\n\t\t\"objects\": 153,
\n\t\t\"geometries\": 144,
\n\t\t\"materials\": 5,
\n\t\t\"textures\": 1\n\t
},
\n\n\t\"urlBaseType\": \"relativeToScene\",
Anyone else having this issue?
The syntax error is a "Unexpected token: ILLEGAL" character, probably thrown by your use of "\n\t\t" and others (escape sequences) outside strings. I don't know what you are trying to achieve with escape sequences outside strings, and I don't even know if special characters should be used in JSON.
Also, I see "\" at some of your strings. You can't use "\". You can, however, use "\", that is escape sequence for a "\". Using a single "\" inside a string will give you the "Unexpected token: ILLEGAL" error. "\" must always be followed by a character that makes a valid escape sequence.
I have an error syntag when i using javascript.
This is my code
FORM RUANG </td>
and the error said "illegal character syntax error unterminated string literal"
Help me please!!!
I'm very confused how to handle it...
You have few mistakes like href=href= then few issues with " as well
FORM RUANG </td>
When I do this:
onClick = "return generateClient('<?php echo json_encode($_POST)?>');"
I am getting this error on the google chrome console.
Uncaught SyntaxError: Unexpected token ILLEGAL
But when I do this from php:
print_r(json_encode($_POST));
I get:
{"lang-select":"C++","question-id":"1","method-name":"Rishi","param-count":"1","lib-path":"c:\\h\\b.out","return-select":"unsigned int","sample-count":"1","class-name":"m"}
What can be the fault in this?
Your data contains " characters.
Your attribute values are delimited by " characters.
The first " in the data will end the attribute value.
A validator would have picked this up for you.
Run your data through htmlspecialchars to encode the quote marks.
i'm doing a simple parse of some JSON and it's giving me an error in chrome, what am i missing here?
Ext.util.JSON.decode("{info: {synopsis: 'test'}}");
SyntaxError: Unexpected token ILLEGAL
Thanks a lot
http://www.json.org/
Think you should use double quotes instead of single quotes.
Ext.util.JSON.decode('{"info": {"synopsis": "test"}}');
Be careful if you are using ExtJs 4 onward, You have to use
Ext.JSON.decode('{"info": {"synopsis": "test"}}');