sponsored links



No announcement yet.

Web service at two levels : merge a complete Json in another Json (via YAJL)

  • Filter
  • Time
  • Show
Clear All
new posts

  • Web service at two levels : merge a complete Json in another Json (via YAJL)

    Hallo to everyone,

    I need to insert a JSON file like a field of another JSON file.
    The scenario is this : I have yet ready a WSS that give me back a complex Json about customer order. This is developed via IWS and I'd like to reuse it.
    Now I have the necessity to give back information about a lot of orders, for example all the orders of the same customer. So I need a bigger Json output. I can't do this with IWS, due to the limit of 16 MB.
    So I develop a my own web server (following Mr. Scott instructions, YAILSERVER) that received a Json request via POST and have to give back like result another Json.
    The idea was to call the existing WSS for every order and merge all the json in one big unique flow.
    To do this I use the yajl_addCharPtr instructions. But I have the problem that insert escape character for every json field. For example :

    [{"environment_db":"AS400","company_cod":"RUI","ord er_no":

    while should be [{"environment_db":"AS400"," and so on

    Perhaps I undestood bad, but using yajl_genOpen(*on:*on); doesn't change the result.

    I tried so to work directly with yajl buffer

    rc = yajl_getBuf(yajl_buffer_ptr: yajl_buffer_len) ;

    but I am not able to expand the buffer with additional data. A memcopy instructions not function

    memcpy(yajl_buffer_ptr + offset : %addr(megaDS): megaDs_len) ;

    I suppose that in same way I have to incremente the memory for the buffer ... But I am not able to find how to do it.

    Someone that in past encountered the same problem ?

    Best regards

    Nalesso Antonio

  • #2

    yajl_addCharPtr() is for adding a new character field to a JSON document. It is not for inserting JSON nodes from an existing document. These are two very different things.

    yajl_getBuf() is to get the raw YAJL buffer. You should NEVER make changes to that buffer.. all of the code inside YAJL expects it to be unchanged, if you start changing it, that code will not work correctly and it will lead to unpredictable results, possibly even make your server unstable. The data from YAJL_getBuf() should always be treated as "read only". In fact, unless you are an expert with pointers, I would recommend never using yajl_getBuf() for any reason.

    To add data from another JSON document, you should load that document into a tree. You can do that with any of YAJL's functions for loading a tree such as yajl_stmf_load_tree, yajl_string_load_tree, etc. Once loaded, use YAJL_genFromNode to copy the nodes from the tree into the YAJL generator.


    sponsored links