Sponsored Links
Sponsored Link

sponsored links

Collapse

Announcement

Collapse
No announcement yet.

First attempt at Data-Into with YAJL parser

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

  • #16
    I don't think there is a workaround Scott - at least not until there is a widespread implementation of a comprehensive schema system for JSON - and even then, just like with XML schemas, they would only be used 30% of the time if that.

    What I was thinking of was a tool that would simply attempt to generate the required names/hierarchy together with the DIMs etc. where needed. Not a complete solution, but for large complex documents it would sure as heck save some time!

    Comment


    • #17
      Originally posted by JonBoy View Post
      I don't think there is a workaround Scott - at least not until there is a widespread implementation of a comprehensive schema system for JSON - and even then, just like with XML schemas, they would only be used 30% of the time if that.

      What I was thinking of was a tool that would simply attempt to generate the required names/hierarchy together with the DIMs etc. where needed. Not a complete solution, but for large complex documents it would sure as heck save some time!
      Agreed! That is really what I was thinking as well... maybe just establish the DS elements & sizes based on the sample data in the JSON. (I don't see how a tool could ever get it exactly right)... but it would at least remove the issues associated with name mismatches and data structure nesting.

      It would then be up to the developer to adjust the data structure. In the case of this API, 50 is the max.

      Comment


      • #18
        Just to update the original post...

        I am able to parse the JSON document and get the elements I need using YAJL without using DATA-INTO. I used the same data structure and assumed the same JSON structure. So I'm not sure what this means (if anything).

        Based on debug, it appears that YAJLINTO is parsing the entire document without error. So there is either something wrong with my DS, or something wrong with DATA-INTO (unlikely).

        The question remaining for me is... When should I use YAJL_object_loop (read each object) versus YAJL_object_find to get the specific objects I need, within the array loop?

        Comment


        • #19
          Originally posted by gwilburn View Post
          When should I use YAJL_object_loop (read each object) versus YAJL_object_find to get the specific objects I need, within the array loop?
          Not sure there are right or wrong times... use whichever makes more sense for what you're coding at the time.

          Comment


          • #20
            I have spent some time parsing this document with YAJL... I'm getting where I need to be. But the process for me is slow and tedious because of the levels of "nesting" I have to parse through to get the data I need. In some cases it (the data) is 5 levels from the document node.

            I've opened a case with IBM to see why DATA-INTO is not populating my DS.

            In the meantime, is there an easier method with YAJL to get directly to a particular nesting level without iterating through all of the nodes?

            Example:

            Code:
            addressnode = YAJL_object_find(ordernode : 'fulfillmentStartInstructions.shippingStep.shipTo.contactAddress');
            j = 0;
            dow YAJL_object_loop( addressnode: j: key: val);
              select: 
              when key = 'addressLine1'; 
                orders(i).address1 = YAJL_get_string(val);
              when key = 'city';
                orders(i).city = YAJL_get_string(val);
              etc...
              endsl;
            enddo;
            Or is there a better way to "drill down" to the correct node?

            Comment

            sponsored links

            Collapse

            Working...
            X