JSON field names with periods

Homepage Clovertech Forums Cloverleaf JSON field names with periods

Tagged: ,

  • Creator
    Topic
  • #118513
    Matthew Rasmussen
    Participant

    If I have a JSON schema that includes periods in field names, the periods get parsed into structural components of the output JSON.  For instance this:

    “MSH”: {
    “MSH.1”: “|”,
    “MSH.2”: “^~\&”,

    …parses as this in translation:
    “MSH”:{
    “MSH”:{
    “1”:”\\|”,
    “2”:”^~\\&”,

    Is there a way to specify literal periods in the field names, without them getting parsed as structural components?

Viewing 1 reply thread
  • Author
    Replies
    • #118524
      Jim Kosloskey
      Participant

      I am not a JSON expert and have done little work with JSON.

      However a little reading on the web indicates periods (dots) in JSON field names may be representative of  a structure and thus not allowed to actually be part of a field name – which is what I think you are seeing via the Xlate.

      The recommendation I saw was to use underscore in place of the period (dot).

      If this is a Schema you built then I would try to replace the periods in field names with underscore.

      If someone else built this schema, then I would try to validate it in one of the free online JSON Schema validation tools. If one or more of the tools indicate an issue with the period (dot), I would present that evidence to the originator of the schema and suggest they send a corrected schema.

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

    • #118525
      Matthew Rasmussen
      Participant

      Hi Jim,

      Funny story – I actually rebuilt the schema yesterday exactly as you suggested, with the underscores – great minds…  I’ll have to get the vendor’s blessing, but we’re redesigning the API in question anyway, so it shouldn’t be too hard to sell.  Especially if I take your additional advise and prove that these names don’t observe JSON best practice.  You can’t blame Cloverleaf for following the rules to the letter. I appreciate you sharing your wisdom and advise!

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

Forum Statistics

Registered Users
5,129
Forums
28
Topics
9,301
Replies
34,447
Topic Tags
288
Empty Topic Tags
10