JSON Question

Clovertech Forums Cloverleaf JSON Question

  • Creator
    Topic
  • #118974
    Jeff Anderson
    Participant

      Is there a way to get the JSON node information so you can use it in an Xlate. For example if I have a JSON

      “address” : {
      “type” : “object”,
      “properties” : {
      “line” : {
      “type” : “string”
      },
      “line2” : {
      “type” : “null”
      },
      “city” : {
      “type” : “string”
      },
      “state” : {
      “type” : “string”
      },
      “zip” : {
      “type” : “string”
      },
      “county” : {
      “type” : “string”
      }
      }

       

      Is there a way to get to iterate through “address” and get the values and the identifying text? Address is simple of course, but I have a client that is sending long strings in another field with punctuation that is hard to parse.

      What I want it to be able to iterate through “address”, pull the fields names and values and put them in OBX segments. I don’t think this is possible, but if I don’t ask I’ll never find out for sure.

      Jeff

    Viewing 3 reply threads
    • Author
      Replies
      • #118975
        Tipu Razaq
        Participant

          I keep getting an error when trying to reply “ERROR: Your reply cannot be created at this time”

        • #118976
          Tipu Razaq
          Participant

            Here’s what the manual says:

             

            • For ITERATE, Cloverleaf only supports the ITERATE action on an array node. In this case, the Basis should be an array node. There is no difference between field, group, and segment under Type. You can select any of these types and use the variable in the address.

             

             

            You can iterate as long as it’s an array node you’re iterating over. Your schema doesn’t have any arrays that I can see. Your best bet may be to use a TCL proc and look into the JSON extension packages, although they’re not the best. Python would be better if you can use that since it supports JSON better.

             

          • #118979
            Jim Kosloskey
            Participant

              So – full disclosure – I have never done a JSON Xlate.

              But can you specify the field as repeating in the JSON Configurator much like HL/7? I assume there is a JSON Configurator. If not and it is like XML, you then should be able to change the JSON Schema via available JSON tools (possibly free) shouldn’t you?

              Again the above offered with a significant dose of ignorance.

               

              email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.

            • #118981
              Jeff Anderson
              Participant

                I ended up putting in a pre-proc to pull the information. Like Tipu wrote, the element has to be an array. I don’t control the format so…  It would be nice if you could iterate on an object and pull the json element values. The example didn’t show it, but what I was dealing with were AOE questions. So it would be nice to get the AOE and answer without having to hard code the AOE. Anyway, thanks for the responses!

                Jeff

            Viewing 3 reply threads
            • You must be logged in to reply to this topic.