TheLever
TheLever

Reputation: 21

What is optional here?

I admit my university days are far gone, and I may be a bit more rusty than I thought.

Was reading this EBNF:

<create_object_expression> ::= '{' [{property_name | "property_name"} : <scalar_expression>][,…n] '}'

I understand it means the expression starts with the literal '{' and ends with '}'. In between those, there is an optional sequence. But, does it also mean that a valid sequence could be "{ : <what ever scalar expression is parsed here> }" since property_name | "property_name" is optional?

Upvotes: 0

Views: 61

Answers (1)

Balaji
Balaji

Reputation: 1795

What is optional here?

As per this document, property_name is not an optional, it acts as a key in the JSON data as you can see below.

{
  "name": "Pavan",
  "age": 30,
  "isStudent": false
}

In the above data name, age and isStudent are property_names. According to EBNF it is a valid format as it starts with { and ends with }.

According to this document, Scalar Expressions doesn't consists of property name as you can see in the below example.

SELECT VALUE ((2 + 11 % 7) - 2) / 2

Output:

[
  2
]

In the above example the output doesn't consists of any property name. Mostly property_name is optional in scalar expressions means any math equations or any boolean results.

Upvotes: 0

Related Questions