mercredi 3 juin 2015

How to get Sqlite column values from sql.js queries

I'm trying to get a column value from a simple two-column sqlite database. The query seems to work fine, but I can't figure out how to get the returned value from the JSON object in the array.

The result of the query is:

[{"columns":["definition"],"values":[["definition 1"]]}] 

What I want is the value in double square brackets at the end ("definition 1").

I got the above value with the following code:

var contents = db.exec("SELECT definition ... ");
alert(JSON.stringify(contents));

What is the most efficient way to get the column value that I want?

Aucun commentaire:

Enregistrer un commentaire