I looked at the test cases for encoding/decoding. Looks like they all deal with json data structures starting with "[" and I couldn't find any method that would do anything similar to what you mentioned:
var hello=[{a:2,b:3}]; console.log(hello.toJSON());
[{"a": 2, "b": 3}] Did you suggest that I should find some library that would help me to evaluate my var hello=[{a:2,b:3}]; to [{"a": 2, "b": 3}] and then use cl-json to decode it to alist?
Andrew
On Tue, Jun 10, 2008 at 10:04 AM, Henrik Hjelte henrik@evahjelte.com wrote:
On Tue, Jun 10, 2008 at 2:00 PM, Andrei Stebakov lispercat@gmail.com wrote:
I was sending the string I mentioned starting with "var Categories =
....".
ok, that was javascript source code, not json. When it is evaluated, it becomes a javascript array. That array can be encoded to Json, for that you need a javascript library to do the encoding. Look at www.json.org for a description of json and for available libraries, I believe that all major javascript frameworks have a json encoder.
For example if you have prototype it adds a method to all arrays:
var hello=[{a:2,b:3}]; console.log(hello.toJSON());
var hello=[{a:2,b:3}]; console.log(hello.toJSON());
[{"a": 2, "b": 3}] (output from Firebug, not the quotes around a and b when it is JSON)
Looks like I somehow need to translate the Categories and DB to some json tree, but I don't know how to do it.
I would look at the test cases for cl-json, they explain fairly well how to do encoding and decoding.
Should I resort to flex/bison or I can just use the libraries available for common lisp?
I don't know anything about flex or bison. But I say it is early to give up at this state, so far the problem has not been with cl-json.
Good luck, Henrik