sponsored links

Collapse

Announcement

Collapse
No announcement yet.

YAJL JSON generation - import existing JSON?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • YAJL JSON generation - import existing JSON?

    So I am writing a CGI program that returns JSON. And naturally I'm using YAJL, since it has the capability of outputting directly to stdout. The JSON is being built with yajl_beginObj() etc.

    And it occurred to me - it would be really handy if I could import some existing JSON into this JSON. E.g. say I had an embedded SQL statement generating JSON into a host varchar, and I then wanted to include that JSON as part of YAJL's JSON generation.

    Is that possible?

  • #2
    YAJL_genFromNode() lets you take JSON that has been parsed with the tree parser (yajl_stdin_load_tree, yajl_stmf_load_tree, yajl_string_load_tree, yajl_buf_load_tree, etc) and generate JSON from a given node. So you could load an existing JSON file, navigate to a given node within that file, and generate output based on that node (and its descendents)

    Or, alternately, there's a new feature YAJL_addPreformattedPtr() that inserts data directly into a file. This routine assumes that the data is already formatted correctly and does not attempt to escape it or modify it in any way. This might be useful for inserting data that was already formatted as JSON from a tool like the SQL JSON generator.

    Comment


    • #3
      Thank you Scott, great advice as always

      Comment

      Working...
      X