Skip to content

Commit d3b6d15

Browse files
authored
Merge pull request #2 from guzba/master
readme suggestions
2 parents 6bbfc71 + bde185a commit d3b6d15

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ With this library you can parse json your way, from the mess you get to the obje
66

77
## Fast/No garbage.
88

9-
Current standard module first parses 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.
9+
Currently the Nim standard module first parses 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.
1010

1111
## Can parse most object types:
1212

@@ -30,7 +30,7 @@ var v = fromJson[Entry1](s)
3030
doAssert v.color == ""
3131
```
3232

33-
## Snake_case or CamelCase
33+
## Converts snake_case to camelCase.
3434

3535
Nim usually uses `camelCase` for its variables, while a bunch of json in the wild uses `snake_case`. This library will convert `snake_case` to `camelCase` for you when reading json.
3636

@@ -49,7 +49,7 @@ doAssert v.colorBlend == "red"
4949

5050
### `proc newHook()` Can be used to populate default values.
5151

52-
Some times absence of a field means it should have a default value. Normally this would just be Nim's default value for the variable type. But with the newHook() you can setup the object with defaults before the main parsing happens.
52+
Sometimes the absence of a field means it should have a default value. Normally this would just be Nim's default value for the variable type but that isn't always what you want. With the newHook() you can set initialize the object your defaults before the main parsing happens.
5353

5454
```nim
5555
type
@@ -68,7 +68,7 @@ doAssert v.visible == "yes"
6868

6969
### `proc enumHook()` Can be used to parse enums.
7070

71-
In wild json enums name almost never match to nim enum names that usually have a prefix. The enumHook() allows you to rename the enums to your internal names.
71+
In the wild json enum names almost never match to Nim enum names which usually have a prefix. The enumHook() allows you to rename the enums to your internal names.
7272

7373
```nim
7474
type Color2 = enum
@@ -90,7 +90,7 @@ doAssert fromJson[Color2](""" "GREEN" """) == c2Green
9090

9191
### `proc renameHook()` Can be used to rename fields at run time.
9292

93-
In wild json field names can be reserved words such as type, class, or array. With the renameHook you can rename fields to what you want on the type you need.
93+
In the wild json field names can be reserved words such as type, class, or array. With the renameHook you can rename fields to what you want.
9494

9595
```nim
9696
type Node = ref object
@@ -118,7 +118,7 @@ proc parseHook(s: string, i: var int, v: var DateTime) =
118118
var dt = fromJson[DateTime](""" "2020-01-01 00:00:00" """)
119119
```
120120

121-
Some times json gives you an object of entries with their id as keys, but you might want it as a sequence with ids inside the objects, again you can do anything with `parseHook()`:
121+
Sometimes json gives you an object of entries with their id as keys, but you might want it as a sequence with ids inside the objects. You can handle this and many other scenarios with `parseHook()`:
122122

123123
```nim
124124
type Entry = object

src/jsony.nim

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ proc parseHook*[T: tuple](s: string, i: var int, v: var T)
1212
proc parseHook*[T: array](s: string, i: var int, v: var T)
1313

1414
template error(msg: string, i: int) =
15-
## Short cut to raise an exception.
15+
## Shortcut to raise an exception.
1616
raise newException(JsonError, msg)
1717

1818
proc eatSpace*(s: string, i: var int) =
19-
## Will consume white space.
19+
## Will consume whitespace.
2020
while i < s.len:
2121
let c = s[i]
2222
if c in whiteSpace:
@@ -296,7 +296,6 @@ proc parseHook*[T](s: string, i: var int, v: var Table[string, T]) =
296296

297297
proc fromJson*[T](s: string): T =
298298
## Takes json and outputs the object it represents.
299-
## * Create little intermediate values.
300299
## * Extra json fields are ignored.
301300
## * Missing json fields keep their default values.
302301
## * `proc newHook(foo: var ...)` Can be used to populate default values.

0 commit comments

Comments
 (0)