Skip to content

Commit eecedd1

Browse files
author
dmitry.rybakov
committed
add simple example to README and upd install cmd
1 parent e57b4c6 commit eecedd1

1 file changed

Lines changed: 24 additions & 3 deletions

File tree

README.md

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,18 @@ standard `encoding/json` package, such as generating "snake_case" names or
1212
enabling `omitempty` behavior by default.
1313

1414
## Usage
15+
### Install:
1516
```sh
16-
# install
17+
# for Go < 1.17
1718
go get -u github.com/mailru/easyjson/...
18-
19-
# run
19+
```
20+
#### or
21+
```sh
22+
# for Go >= 1.17
23+
go get github.com/mailru/easyjson && go install github.com/mailru/easyjson/...@latest
24+
```
25+
### Run:
26+
```sh
2027
easyjson -all <file>.go
2128
```
2229

@@ -28,6 +35,20 @@ environment variable to be set. This is because easyjson code generation
2835
invokes `go run` on a temporary file (an approach to code generation borrowed
2936
from [ffjson](https://github.com/pquerna/ffjson)).
3037

38+
### Serialize
39+
```go
40+
someStruct := &SomeStruct{Field1: "val1", Field2: "val2"}
41+
rawBytes, err := easyjson.Marshal(someStruct)
42+
```
43+
44+
### Deserialize
45+
```go
46+
someStruct := &SomeStruct{}
47+
err := easyjson.Unmarshal(rawBytes, someStruct)
48+
```
49+
50+
Please see the [GoDoc](https://godoc.org/github.com/mailru/easyjson)
51+
for more information and features.
3152
## Options
3253
```txt
3354
Usage of easyjson:

0 commit comments

Comments
 (0)