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

JSLT has working with this array #313

Open
oyeyemi opened this issue Oct 25, 2023 · 3 comments
Open

JSLT has working with this array #313

oyeyemi opened this issue Oct 25, 2023 · 3 comments
Labels
support Users asking how to solve a specific issue

Comments

@oyeyemi
Copy link

oyeyemi commented Oct 25, 2023

Hello sir,
I got to know that JSLT is having problem parsing the following array. It only works when you substitute the [] with {}.

my array:

[ "count": 50,
"ins": {
"in": [
{"type": "value1", "required": "true"},
{"type": "value2", "required": "true"}
]
}
]

Thank you for your help in advance.

@larsga larsga added the support Users asking how to solve a specific issue label Oct 25, 2023
@larsga
Copy link
Collaborator

larsga commented Oct 25, 2023

You get problems because this

[ "count": 50,

isn't correct array syntax.

@oyeyemi
Copy link
Author

oyeyemi commented Oct 26, 2023

Thank you sir for pointing that out.

@catull
Copy link

catull commented Oct 26, 2023

To clarify one point.

In JSON, one object, say an an animal with name, kind and age is displayed as such

{
  "kind": "cat",
  "name": "Tom",
  "age:" 10
}

Now, if you want to express a collection of animals, they have to be enclosed in '[' ...... ']'.

E.g.:

[
  { "kind": "cat", "name": "Tom", "age": 10 },
  { "kind": "mouse", "name": "Jerry", "age": 6 },
  { "kind": "dog", "name": "Spike", "age": 7 }
]

You can have an empty collection / array: [ ].

If the collection is non-empty, you have to have other arrays or objects inside of it.
Just adding a property ( "count": 50 ) by itself is invalid JSON.

What is valid however, is this:

[
  {
     "count": 50,
     "ins": [
        { "type": "value1", "required": "true" },
        { "type": "value2", "required": "true" }
     ]
  }
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
support Users asking how to solve a specific issue
Projects
None yet
Development

No branches or pull requests

3 participants