google / jsonnet

Jsonnet - The data templating language
http://jsonnet.org
Apache License 2.0
6.92k stars 437 forks source link

ERROR: incorrect string and dict handling #1166

Open rprtr258 opened 1 month ago

rprtr258 commented 1 month ago

Using

$ jsonnet --version
Jsonnet commandline interpreter (Go implementation) v0.20.0

with following expression:

"1" {}
// or
["1" {}]

expecting syntax error, comma expected, but got

"1{ }"
// or
[
  "1{ }"
]

Works in playground too.

Found while generated xml from incorrect input that was like

["article" {id: "main", class: "markdown-section", role: "main", tabindex: "-1"}, "text"]

which was handled incorrectly before xml-transform to

[
  "article{\"class\": \"markdown-section\", \"id\": \"main\", \"role\": \"main\", \"tabindex\": \"-1\"}",
  "text"
]

while expected

[
  "article",
  {
    "class": "markdown-section",
    "id": "main",
    "role": "main",
    "tabindex": "-1"
  },
  "text"
]