JSON fields with commas

Clovertech Forums Cloverleaf JSON fields with commas

Tagged: 

  • Creator
    Topic
  • #115664
    Ken Smith
    Participant

      I am mapping from HL7 2.4 to bespoke JSON format, with standard delimiter of comma for field. Everything works fine except for one thing. The customer has asked for the address fields to be concatenated into a single field, with the separate subfields delimited by commas, e.g., “Flat 1 Somewhere Apt, Main Street, London N2 3JJ”.

      Problem is that when the parser hits the comma in the concatenated string, it sees it as the field delimiter, so all that maps across is “Flat 1 Somewhere Apt”. I’ve tried a standard escape character, e.g., “\,”, and tried placing double quotes around the whole string.

      Has anyone faced and dealt with this type of scenario in Cloverleaf?

    Viewing 1 reply thread
    • Author
      Replies
      • #115665
        Peter Heggie
        Participant

          The same thing happens with the Cloverleaf Database protocol. When it retrieves specified columns from a table, the columns values are separated by commas. If the data contains commas, everything is thrown off. In the beginning of working with this I tried to escape the commas but was unsuccessful. I ended up doing mass find/replaces of embedded commas to spaces or semicolons.

          However – at least for database access – the DB Schema wizard allows you to select a table and then select the columns you want to work with. When you save that configuration, Cloverleaf creates a VRL file in …/<site>/formats/<database>/dbschema. In that VRL is a specification for the field separator. The value is a comma. I have not tried it but possibly that schema could be manually edited to change that separator character.

          Possibly the JSON schema is stored in a similar fashion, and you can update the field separator specifier? But I don’t know what else that might impact.

          HTH

          Peter

          Peter Heggie

        • #115667
          Ken Smith
          Participant

            Thanks for your response. I’ve been working across the boundaries between Cloverleaf 6.2 and Cloverleaf 19.1, as we prepare to switch over to the latter. I’d been working initially with HL7 to VRL (comma delimited fields) and couldn’t get commas to work. When I was finally able to switch over to a proper JSON schema in Cloverleaf 19 and map from HL7 to JSON, the concatenation did work, so I am getting

            “1 Leabridge Road,London, SE1 9BG”

            in the output.

        Viewing 1 reply thread
        • You must be logged in to reply to this topic.