1

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

1 Answer 1

1

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 }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.