hjson icon indicating copy to clipboard operation
hjson copied to clipboard

multiple unquoted strings per line

Open onechip opened this issue 4 years ago • 1 comments

I realize the spec says maximum one unquoted string value per line, but I think there is room to relax that restriction. In testing with hjson-cpp I find that:

{ 
  day: [ weekend, holiday ]
  schedule: [
    { vals: [1,2,3] }
  ]
}

is successfully parsed, but as:

{
  "day": [
    "weekend, holiday ]",
    "schedule: [",
    {
      "vals": [
        1,
        2,
        3
      ]
    }
  ]
}

That's not ideal. Quoting the strings "weekend" and "holiday" resolves the problem.

Also, this works fine: { one: 1, two: 2, three: 3, other: null } but this one fails to parse: { one: 1, two: 2, three: 3, other: none }

Perhaps the following rule could be added to the spec.

When an unquoted array/object value appears on the same line as the array/object opening bracket/brace, the value will end at the first occurrence of any one of the characters , ] }

By limiting this rule to values which appear on the same line as the opening bracket/brace, the following will still work:

{
  this: is OK though: {}[],:
}

onechip avatar Jan 08 '22 19:01 onechip

At this point, I'm not really sure we can make breaking changes to the Hjson spec without causing issues for the people who use it, but I think it's a nice idea. If we were going to make this change to the spec, would we accommodate for the (likely tiny) number of Hjson users who write something like this?

{ path: .spec.containers[1].image
}

And how would we communicate to our users about it?

dqsully avatar Jan 08 '22 20:01 dqsully