Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmark, examples, update README, fix bug
- Loading branch information
1 parent
7bf832e
commit 2d7f5c0
Showing
5 changed files
with
99 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/TylerBrock/colorjson" | ||
"encoding/json" | ||
) | ||
|
||
func main() { | ||
str := `{ | ||
"str": "foo", | ||
"num": 100, | ||
"bool": false, | ||
"null": null, | ||
"array": ["foo", "bar", "baz"], | ||
"obj": { "a": 1, "b": 2 } | ||
}` | ||
|
||
var obj map[string]interface{} | ||
json.Unmarshal([]byte(str), &obj) | ||
|
||
// Make a custom formatter with indent set | ||
f := colorjson.NewFormatter() | ||
f.Indent = 4 | ||
|
||
// Marshall the Colorized JSON | ||
s, _ := f.Marshal(obj) | ||
fmt.Println(string(s)) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/TylerBrock/colorjson" | ||
"encoding/json" | ||
) | ||
|
||
func main() { | ||
str := `{ | ||
"str": "foo", | ||
"num": 100, | ||
"bool": false, | ||
"null": null, | ||
"array": ["foo", "bar", "baz"], | ||
"obj": { "a": 1, "b": 2 } | ||
}` | ||
|
||
var obj map[string]interface{} | ||
json.Unmarshal([]byte(str), &obj) | ||
|
||
// Marshall the Colorized JSON | ||
s, _ := colorjson.Marshal(obj) | ||
fmt.Println(string(s)) | ||
} | ||
|