@@ -14,10 +14,10 @@ framework. The following is available but not an exhaustive list of features:
1414 - Decode into Nim data types efficiently without an intermediate token.
1515 - Able to parse full spec of JSON including the notorious JSON number.
1616 - Support stdlib/JsonNode out of the box.
17- - While stdlib/JsonNode does not support the full spec of the Json number, we offer an alternative ` JsonValueRef ` .
18- - Skipping Json value is an efficient process, no token is generated at all and at the same time, the grammar is checked.
17+ - While stdlib/JsonNode does not support the full spec of the JSON number, we offer an alternative ` JsonValueRef ` .
18+ - Skipping JSON value is an efficient process, no token is generated at all and at the same time, the grammar is checked.
1919 - Skipping is also free from custom serializer interference.
20- - An entire Json value can be parsed into a valid Json document string. This string document can be parsed again without losing any information.
20+ - An entire JSON value can be parsed into a valid JSON document string. This string document can be parsed again without losing any information.
2121 - Custom serialization is easy and safe to implement with the help of many built-in parsers.
2222 - Nonstandard features are put behind flags. You can choose which features to switch on or off.
2323 - Because the intended usage of this library will be in a security-demanding application, we make sure malicious inputs will not crash
@@ -41,8 +41,8 @@ But you can access them using the flags:
4141 - ** relaxedEscape[ =off] ** : only '0x00'..'0x1F' can be prepended by escape char ` \\ ` , turn this on and you can escape any char.
4242 - ** portableInt[ =off] ** : set the limit of integer to ` -2**53 + 1 ` and ` +2**53 - 1 ` .
4343 - ** trailingComma[ =on] ** : allow the presence of a trailing comma after the last object member or array element.
44- - ** allowComments[ =on] ** : JSOn standard doesn't mention about comments. Turn this on to parse both C style comments of ` //..EOL ` and ` /* .. */ ` .
45- - ** leadingFraction[ =on] ** : something like ` .123 ` is not a valid JSON number, but its widespread usage sometimes creeps into Json documents.
44+ - ** allowComments[ =on] ** : JSON standard doesn't mention about comments. Turn this on to parse both C style comments of ` //..EOL ` and ` /* .. */ ` .
45+ - ** leadingFraction[ =on] ** : something like ` .123 ` is not a valid JSON number, but its widespread usage sometimes creeps into JSON documents.
4646 - ** integerPositiveSign[ =on] ** : ` +123 ` is also not a valid JSON number, but since ` -123 ` is a valid JSON number, why not parse it safely?
4747
4848## Safety features
@@ -58,15 +58,15 @@ You can modify these default configurations to suit your needs.
5858
5959## Special types
6060
61- - ** JsonString** : Use this type if you want to parse a Json value to a valid Json document contained in a string.
62- - ** JsonVoid** : Use this type to skip a valid Json value.
63- - ** JsonNumber** : Use this to parse a valid Json number including the fraction and exponent part.
61+ - ** JsonString** : Use this type if you want to parse a JSON value to a valid JSON document contained in a string.
62+ - ** JsonVoid** : Use this type to skip a valid JSON value.
63+ - ** JsonNumber** : Use this to parse a valid JSON number including the fraction and exponent part.
6464 - Please note that this type is a generic, it support ` uint64 ` and ` string ` as generic param.
6565 - The generic param will define the integer and exponent part as ` uint64 ` or ` string ` .
6666 - If the generic param is ` uint64 ` , overflow can happen, or max digit limit will apply.
6767 - If the generic param is ` string ` , the max digit limit will apply.
6868 - The fraction part is always a string to keep the leading zero of the fractional number.
69- - ** JsonValueRef** : Use this type to parse any valid Json value into something like stdlib/JsonNode.
69+ - ** JsonValueRef** : Use this type to parse any valid JSON value into something like stdlib/JsonNode.
7070 - ` JsonValueRef ` is using ` JsonNumber ` instead of ` int ` or ` float ` like stdlib/JsonNode.
7171
7272## Flavor
@@ -268,22 +268,22 @@ type
268268 Fruit = enum
269269 Apple = "Apple"
270270 Banana = "Banana"
271-
271+
272272 Drawer = enum
273273 One
274274 Two
275-
275+
276276 Number = enum
277277 Three = 3
278278 Four = 4
279-
279+
280280 Mixed = enum
281281 Six = 6
282282 Seven = "Seven"
283283```
284284
285285nim-json-serialization automatically detect which representation an enum should be parsed.
286- The detection occurs when parse json literal and from the enum declaration itself.
286+ The detection occurs when parse JSON literal and from the enum declaration itself.
287287'Fruit' expect string literal. 'Drawer' or 'Number' expect numeric literal.
288288'Mixed' is disallowed. If the json literal does not match the expected enum style,
289289exception will be raised. But you can configure individual enum type with:
@@ -292,7 +292,7 @@ exception will be raised. But you can configure individual enum type with:
292292configureJsonDeserialization(
293293 T: type[enum], allowNumericRepr: static[bool] = false,
294294 stringNormalizer: static[proc(s: string): string] = strictNormalize)
295-
295+
296296# example:
297297Mixed.configureJsonDeserialization(allowNumericRepr = true) # only at top level
298298```
0 commit comments