You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All methods throw `Nette\Neon\Exception` on error.
64
66
67
+
<!---->
65
68
66
69
Integration
67
70
===========
@@ -84,6 +87,8 @@ You can check for syntax errors in Neon files using the `neon-lint` console comm
84
87
vendor/bin/neon-lint <path>
85
88
```
86
89
90
+
<!---->
91
+
87
92
Syntax
88
93
======
89
94
@@ -176,11 +181,11 @@ Values of mappings and sequences may be other mappings and sequences. The level
176
181
177
182
```neon
178
183
pets:
179
-
- Cat
180
-
- Dog
184
+
- Cat
185
+
- Dog
181
186
cars:
182
-
- Volvo
183
-
- Skoda
187
+
- Volvo
188
+
- Skoda
184
189
```
185
190
186
191
In PHP, the same structure would be written as:
@@ -218,6 +223,28 @@ item: [
218
223
]
219
224
```
220
225
226
+
In the previous case, we wrote a mapping whose elements were sequences. Now, let's try it the other way around and create a sequence containing mappings:
227
+
228
+
```neon
229
+
-
230
+
name: John
231
+
age: 35
232
+
-
233
+
name: Peter
234
+
age: 28
235
+
```
236
+
237
+
It's not necessary for the bullet points to be on separate lines; they can also be placed in this manner:
238
+
239
+
```neon
240
+
- name: John
241
+
age: 35
242
+
- name: Peter
243
+
age: 28
244
+
```
245
+
246
+
It's up to you whether you align the keys in a column using spaces or a tab.
247
+
221
248
Because PHP uses the same structure for mapping and sequences, that is, arrays, both can be merged. The indentation is the same this time:
222
249
223
250
```neon
@@ -236,6 +263,7 @@ In PHP, the same structure would be written as:
236
263
]
237
264
```
238
265
266
+
239
267
Strings
240
268
-------
241
269
Strings in NEON can be enclosed in single or double quotes. But as you can see, they can also be without quotes.
@@ -246,7 +274,7 @@ Strings in NEON can be enclosed in single or double quotes. But as you can see,
246
274
- "A double-quoted string in NEON"
247
275
```
248
276
249
-
If the string contains characters that can be confused with NEON syntax (hyphens, colons, etc.), it must be enclosed in quotation marks. We recommend using single quotes because they do not use escaping. If you need to enclose a quotation mark in such a string, double it:
277
+
If the string contains characters `# " ' , : = - [ ] { } ( )`that can be confused with NEON syntax, it must be enclosed in quotation marks. We recommend using single quotes because they do not use escaping. If you need to enclose a quotation mark in such a string, double it:
250
278
251
279
```neon
252
280
'A single quote '' inside a single-quoted string'
@@ -265,7 +293,7 @@ There are other cases where you need to enclose strings in quotation marks:
265
293
- NEON would understand them as [dates](#dates)
266
294
267
295
268
-
Multiline strings
296
+
Multiline Strings
269
297
-----------------
270
298
271
299
A multiline string begins and ends with a triple quotation mark on separate lines. The indent of the first line is ignored for all lines:
@@ -307,6 +335,7 @@ NEON understands numbers written in so-called scientific notation and also numbe
307
335
- 0x7A # hexa number
308
336
```
309
337
338
+
310
339
Nulls
311
340
-----
312
341
Null can be expressed in NEON by using `null` or by not specifying a value. Variants with a capital first or all uppercase letters are also allowed.
@@ -316,6 +345,7 @@ a: null
316
345
b:
317
346
```
318
347
348
+
319
349
Booleans
320
350
--------
321
351
Boolean values are expressed in NEON using `true` / `false` or `yes` / `no`. Variants with a capital first or all uppercase letters are also allowed.
@@ -324,6 +354,7 @@ Boolean values are expressed in NEON using `true` / `false` or `yes` / `no`. Var
324
354
[true, TRUE, True, false, yes, no]
325
355
```
326
356
357
+
327
358
Dates
328
359
-----
329
360
NEON uses the following formats to express data and automatically converts them to `DateTimeImmutable` objects:
@@ -345,7 +376,7 @@ An entity is a structure that resembles a function call:
345
376
Column(type: int, nulls: yes)
346
377
```
347
378
348
-
In PHP, it is parsed as an object [Nette\Neon\Entity](https://api.nette.org/3.0/Nette/Neon/Entity.html):
379
+
In PHP, it is parsed as an object [Nette\Neon\Entity](https://api.nette.org/3.4/Nette/Neon/Entity.html):
349
380
350
381
```php
351
382
// PHP
@@ -390,7 +421,7 @@ country: USA
390
421
```
391
422
392
423
393
-
NEON versus JSON
424
+
NEON Versus JSON
394
425
================
395
426
JSON is a subset of NEON. Each JSON can therefore be parsed as NEON:
0 commit comments