Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Arrays of dictionaries with same keys #178

Closed
raman2805 opened this issue May 17, 2016 · 4 comments
Closed

Arrays of dictionaries with same keys #178

raman2805 opened this issue May 17, 2016 · 4 comments

Comments

@raman2805
Copy link

The follow ill formatted json

[
    {
      "Value": 1.25
    } 
    {
      "Value": 2.5 
    }
]

gets converted to

[
    {
      "Value": 2.5
    }
]

I would expect it to get converted to

[
    {
      "Value": 1.25
    }, 
    {
      "Value": 2.5 
    }
]
@igorpeshansky
Copy link
Contributor

The second object overrides the first when the comma is missing, doesn't it?
Igor

On Tue, May 17, 2016 at 10:55 AM, Raman Khatri notifications@github.com
wrote:

The follow ill formatted json

[
{
"Value": 1.25
}
{
"Value": 2.5
}
]

gets converted to

[
{
"Value": 2.5
}
]

I would expect it to get converted to

[
{
"Value": 1.25
},
{
"Value": 2.5
}
]


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#178

@raman2805
Copy link
Author

Is this part of the documentation, maybe I missed it. Can this be disabled or this is an intended feature ?

@mikedanese
Copy link
Contributor

mikedanese commented May 17, 2016

@igorpeshansky is right. In the spec:

desugar(expr { ... }, b)    =   desugar(expr + { ... }, b)

Which means:

{ "Value": 1.25} {"Value": 2.5}

is desugared to:

{ "Value": 1.25} + {"Value": 2.5}

This is a language feature meant to allow convinient mixin syntax

@sparkprime
Copy link
Member

Yeah it's "unfortunate" that in this case forgetting a comma results in
different behavior rather than an error. But it is intended, e.g. the
first example on jsonnet.org uses it:
person2: self.person1 { name: "Bob" }

On Tue, May 17, 2016 at 12:05 PM Mike Danese notifications@github.com
wrote:

@igorpeshansky https://github.com/igorpeshansky is right. In the spec
http://jsonnet.org/language/spec.html:

desugar(expr { ... }, b) = desugar(expr + { ... }, b)

Which means:

{ "Value": 1.25} {"Value": 2.5}

is desugared to:

{ "Value": 1.25} + {"Value": 2.5}

This is a language feature meant to allow convinient syntax


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
#178 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants