Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 4 years ago.
Improve this question
I have this simple local.JSON file I use with node-config:
{
"MySQL": {
"connection": "mysql://root:foo#localhost/heroku_d093ad5a46d841c?reconnect=true",
},
"Mongoose": {
"connection": "mongodb://localhost/myapp"
}
}
However, I get this error from nodemon:
Error: Cannot parse config file:
'/Users/foo/root/repo_fave/config/local.json': SyntaxError:
Unexpected token } in JSON at position 110
Particularly what does the 110 refer to. Is it the 110th character if the file was treated as a single line of string?
There is a typo in your JSON. In the MySQL block you have:
"MySQL": {
"connection": "mysql://root:foo#localhost/heroku_d093ad5a46d841c?reconnect=true",
},
This should be:
"MySQL": {
"connection": "mysql://root:foo#localhost/heroku_d093ad5a46d841c?reconnect=true"
},
Please note the removed comma at the end of the inner line. And yes, the 110 refers to the 110th character.
PS: To figure out what problems like these are, you might be interested in JSONLint, a website to validate (and find errors in) JSON.
Related
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
I'm trying to get JSON in a valid format so that it can be sent to an API and I can't figure out why the below JSON is not valid. Please can someone explain why this is not valid?
{
"Description": "test",
"Quantity": "0.30",
"UnitAmount": "6400.0",
"TaxType": "OUTPUT2",
"AccountCode": "200"
},
{
"Description": "test2",
"Quantity": "0.30",
"UnitAmount": "0.0",
"TaxType": "OUTPUT2",
"AccountCode": "200"
}
The top level of a JSON text must be one of the JSON data types (like object, array, or string).
There can only be one data type at the top level.
You have an object but then you have a comma and then a second object.
Perhaps you should wrap it in an array.
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 1 year ago.
Improve this question
const data = [{
"detectedLanguage": {
"language": "hi",
"score": 1
},
"translations": [{
"text": "long steff",
"to": "en"
}]
}]
How do I console.log only the translation.text field?
I tried console.log(JSON.stringify(res.data.translation.text) but that gives me the following error:
TypeError: Cannot read property 'text' of undefined
Try this,
console.log(data[0].translations[0].text)
No need to use Json.stringify, because data[0].translations[0].text is not a Json, it is a string.
You created arrays and am missing the index and the "s" in translations:
console.log(JSON.stringify(data[0].translations[0].text))
I also don't know why you're referencing it as res.data
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 2 years ago.
Improve this question
Hi im pretty sure what im about to post might not be enough info (if so please let me know what more is needed). I am using node js and having a really weird error. Below is the code and output.
if (currentPrice > variableData[i].stopLossHard) {
console.log('if')
console.log(currentPrice)
console.log('is more than')
console.log(variableData[i].stoplossHard)
}
Output:
if
92.7
is more than
93.62700000000001
This is consistently happening. I also made sure that both currentPrice and variableData[i].stopLossHard are numbers and not strings (I made sure in the code and in the output its the color of a number not a string)
Any ideas is highly appreciated.
The attribute you print is different than the one you check in the if statement:
(In the if stopLossHard has a capital L, stop-L-ossHard, what you print doesn't)
Try this:
if (currentPrice > variableData[i].stoplossHard) {
console.log('if')
console.log(currentPrice)
console.log('is more than')
console.log(variableData[i].stoplossHard)
}
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
So, me and a few friends are making a text adventure in JavaScript. in it, there is a possibility of the player using a heal spell, which runs the following code:
function heal() {
alert('You chant some ominous-sounding words, and your wounds heal');
alert('Hit points restored!');
hitPoints += 60;
blobsOfDoom -= 30;
burn();
MonsAtt();
Choose Spell();
}
Error Messages:
Firefox:
/*
Exception: SyntaxError: missing ; before statement
#Scratchpad/1:2703
*/
Chrome:
SyntaxError: Unexpected identifier.
Why is this error showing up? How do I fix it?
You cant have spaces in functions
Choose Spell();
Check your function declaration for ChooseSpell and any other occurances, and change them to a valid function name, like chooseSpell()
Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I have json data I'm having difficulty turning into a string. How can I format it so that it can become strings?
jsfiddle: http://jsfiddle.net/s97QX/2/
code:
Jsonvar = {"shows":[{"show_id":6387, "shownum":6387,"title":"The Protestant's Dilemma","guest":"Devin Rose","category":"Non-Catholic","url":"http://www.catholic.com/radio/shows/the-protestants-dilemma-11565","audiourl":"http://www.catholic.com/sites /default/files/audio/radioshows/ca140331b.mp3","datetime":"1396317600","description":"
Devin Rose <\/p>","thumbnailsmall":"http://www.catholic.com/sites/default/files/imagecache/profile_square_small/images/profilepics/a109aad8daa70ad8976ffc.L._V387899120_SX200_.jpg","thumbnaillarge":"http://www.catholic.com/sites/default/files/imagecache/profile_square_large/images/profilepics /a109aad8daa70ad8976ffc.L._V387899120_SX200_.jpg"}]};
var jsonstr=JSON.stringify(Jsonvar);
alert(jsonstr);
First You validate your json using jsonlint.
JSONLINT
then try.
This error in the console explains it:
Uncaught SyntaxError: Unexpected token ILLEGAL
You have a line break in your object:
Jsonvar = {"shows":[{"show_id":6387, "shownum":6387,"title":"The Protestant's Dilemma","guest":"Devin Rose","category":"Non-
Catholic","url":"http://www.catholic.com/radio/shows/the-protestants-dilemma-
11565","audiourl":"http://www.catholic.com/sites/default/files/audio/radioshows/ca140331b.mp3"
,"datetime":"1396317600","description":" <<<- Here
Devin Rose
Remove that and that property will become a valid string, therefore you'll be able to stringify it