I don't know the right way to store JSON object in a sqlite text field, using nodejs sqlite3 driver. I did the following:
Before write it to the table I tried JSON.stringify(jobj), now jstr value looks like {"melicode":9876543210}
But when I log jstr after select it:
console.log(jstr) # => { melicode :9876543210} no double quote inside
And, JSON.parse(jstr) fails with SyntaxError: Unexpected token m
Add a comment
|
1 Answer
Two things of note:
First, the result of your query is an Object, not a String. So attempting to parse it should result in an exception.
Second, Node's console.log does not render JavaScript objects in JSON notation. You can try that in the repl:
$ node
> console.log({"test": 123});
{ test: 123 }