Skip to content

Commit 9d4b950

Browse files
authored
Merge pull request #41 from dflock/patch-1
Spelling/grammar fixes
2 parents 2a2cc43 + c03782e commit 9d4b950

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

README.md

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This library has no dependencies other than the Nim standard library.
1010

1111
## About
1212

13-
Real world json is *never what you want*. It might have extra fields that you don't care about. It might have missing fields requiring default values. It might change or grow new fields at any moment. Json might use `camelCase` or `snake_case`. It might use inconsistent naming.
13+
Real world json is _never what you want_. It might have extra fields that you don't care about. It might have missing fields requiring default values. It might change or grow new fields at any moment. Json might use `camelCase` or `snake_case`. It might use inconsistent naming.
1414

1515
With this library you can use json your way, from the mess you get to the objects you want.
1616

@@ -21,14 +21,14 @@ With this library you can use json your way, from the mess you get to the object
2121

2222
## Fast.
2323

24-
Currently the Nim standard module first parses or serializes json into JsonNodes and then turns the JsonNodes into your objects with the `to()` macro. This is slower and creates unnecessary work for the garbage collector. This library skips the JsonNodes and creates the objects you want directly.
24+
Currently, the Nim standard module first parses or serializes json into JsonNodes and then turns the JsonNodes into your objects with the `to()` macro. This is slower and creates unnecessary work for the garbage collector. This library skips the JsonNodes and creates the objects you want directly.
2525

2626
Another speed up comes from not using `StringStream`. Stream has a function dispatch overhead because it has to be able to switch between `StringStream` or `FileStream` at runtime. Jsony skips the overhead and just directly reads or writes to memory buffers.
2727

2828
Another speed up comes from parsing and readings its own numbers directly from memory buffer. This allows it to bypass `string` allocations that `parseInt` or `$` create.
2929

30-
3130
### Serialize speed
31+
3232
```
3333
name ............................... min time avg time std dv times
3434
treeform/jsony ..................... 1.317 ms 1.365 ms ±0.054 x100
@@ -39,6 +39,7 @@ nim std/json ....................... 8.222 ms 8.510 ms ±0.123 x100
3939
```
4040

4141
### Deserialize speed
42+
4243
```
4344
name ............................... min time avg time std dv times
4445
treeform/jsony ..................... 4.134 ms 4.196 ms ±0.052 x100
@@ -49,19 +50,19 @@ nim std/json ...................... 14.326 ms 14.473 ms ±0.113 x100
4950

5051
Note: If you find a faster nim json parser or serializer let me know!
5152

52-
## Can parse or serializer most types:
53+
## Can parse or serialize most types:
5354

54-
* numbers and strings
55-
* seq and arrays
56-
* objects and ref objects
57-
* options
58-
* enums
59-
* tuples
60-
* characters
61-
* `HashTable`s and `OrderedTable`s
62-
* `HashSet`s and `OrderedSet`s
63-
* json nodes
64-
* and `parseHook()` enables you to parse any type!
55+
- numbers and strings
56+
- seq and arrays
57+
- objects and ref objects
58+
- options
59+
- enums
60+
- tuples
61+
- characters
62+
- `HashTable`s and `OrderedTable`s
63+
- `HashSet`s and `OrderedSet`s
64+
- json nodes
65+
- and `parseHook()` enables you to parse any type!
6566

6667
## Not strict.
6768

@@ -94,7 +95,7 @@ doAssert v.colorBlend == "red"
9495

9596
Hooks are a powerful concept that allows you to parse json "your way" and is the main idea behind `jsony`!
9697

97-
* Note: that hooks need to be exported to where you are parsing the json so that the parsing system can pick them up.
98+
- Note: that hooks need to be exported to where you are parsing the json so that the parsing system can pick them up.
9899

99100
### `proc newHook*()` Can be used to populate default values.
100101

@@ -117,7 +118,7 @@ doAssert v.visible == "yes"
117118

118119
### `proc postHook*()` Can be used to run code after the object is fully parsed.
119120

120-
Some times we need run some code after the object is created. For example to set other values based on values that where set but are not part of the json data. Maybe to sanitize the object or convert older versions to new versions. Here I need to retain the original size as I will be messing with the object's regular size:
121+
Sometimes we need run some code after the object is created. For example to set other values based on values that were set but are not part of the json data. Maybe to sanitize the object or convert older versions to new versions. Here I need to retain the original size as I will be messing with the object's regular size:
121122

122123
```nim
123124
type Sizer = object
@@ -211,6 +212,7 @@ let s = data.fromJson(seq[Entry])
211212
```
212213

213214
Gives us:
215+
214216
```
215217
@[
216218
(id: "1", count: 12, filled: 11),
@@ -219,7 +221,7 @@ Gives us:
219221
]"""
220222
```
221223

222-
### `proc dumpHook*()` Can be used to serializer into custom representation.
224+
### `proc dumpHook*()` Can be used to serialize into custom representation.
223225

224226
Just like reading custom data types you can also write data types with `dumpHook*()`.
225227
The `dumpHook()` will receive the incomplete string representation of a given serialization (here `s`).
@@ -243,19 +245,20 @@ let s = f.toJson()
243245
```
244246

245247
Gives us:
248+
246249
```
247250
"10/13"
248251
```
249252

250253
## Static writing with `toStaticJson`.
251254

252-
Some times you have or const json and you want to write it in a static way. There is a special function for that:
255+
Sometimes you have some json, and you want to write it in a static way. There is a special function for that:
253256

254257
```nim
255258
thing.toStaticJson()
256259
```
257260

258-
Make sure `thing` is a `static` or a `const` value and you will get a compile time string with your JSON.
261+
Make sure `thing` is a `static` or a `const` value, and you will get a compile time string with your JSON.
259262

260263
## Full support for case variant objects.
261264

@@ -268,11 +271,11 @@ type RefNode = ref object
268271
of nkFloat: floatVal: float
269272
```
270273

271-
The discriminator do no have to come first, if they do come in the middle this library will scan the object, find the discriminator field, then rewind and parse the object normally.
274+
The discriminator does not have to come first, if they do come in the middle this library will scan the object, find the discriminator field, then rewind and parse the object normally.
272275

273276
## Full support for json-in-json.
274277

275-
Some times your json objects could contain arbitrary json structures,
278+
Sometimes your json objects could contain arbitrary json structures,
276279
maybe event user defined, that could only be walked as json nodes. This library allows you to parse json-in-json were you parse some of the structure as real nim objects but leave some parts of it as Json Nodes to be walked later with code:
277280

278281
```nim

0 commit comments

Comments
 (0)