-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
51 additions
and
51 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,60 @@ | ||
# jsun | ||
this is a go json tool like encode/json but allow you to use camelName/CamelName or under_score name style | ||
` | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/JessonChan/jsun" | ||
) | ||
|
||
type Person struct { | ||
Id int | ||
FirstName string | ||
LastName string `json:"name"` | ||
} | ||
|
||
func main() { | ||
p := Person{ | ||
Id: 1, | ||
FirstName: "FirstName", | ||
LastName: "LastName", | ||
} | ||
jsun.UnderScoreStyle() | ||
b, _ := jsun.Marshal(&p) | ||
fmt.Println(string(b)) | ||
} | ||
|
||
"github.com/JessonChan/jsun" | ||
) | ||
|
||
type Person struct { | ||
Id int | ||
FirstName string | ||
LastName string `json:"name"` | ||
} | ||
|
||
func main() { | ||
p := Person{ | ||
Id: 1, | ||
FirstName: "FirstName", | ||
LastName: "LastName", | ||
} | ||
jsun.UnderScoreStyle() | ||
b, _ := jsun.Marshal(&p) | ||
fmt.Println(string(b)) | ||
} | ||
` | ||
output | ||
{"id":1,"first_name":"FirstName","name":"LastName"} | ||
|
||
` | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
> {"id":1,"first_name":"FirstName","name":"LastName"} | ||
|
||
package main | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/JessonChan/jsun" | ||
) | ||
|
||
type Person struct { | ||
Id int | ||
FirstName string | ||
LastName string `json:"name"` | ||
} | ||
|
||
func main() { | ||
p := Person{ | ||
Id: 1, | ||
FirstName: "FirstName", | ||
LastName: "LastName", | ||
} | ||
b, _ := jsun.Marshal(&p) | ||
fmt.Println(string(b)) | ||
} | ||
|
||
"github.com/JessonChan/jsun" | ||
) | ||
|
||
type Person struct { | ||
Id int | ||
FirstName string | ||
LastName string `json:"name"` | ||
} | ||
|
||
func main() { | ||
p := Person{ | ||
Id: 1, | ||
FirstName: "FirstName", | ||
LastName: "LastName", | ||
} | ||
b, _ := jsun.Marshal(&p) | ||
fmt.Println(string(b)) | ||
} | ||
` | ||
output | ||
{"id":1,"firstName":"FirstName","name":"LastName"} | ||
|
||
|
||
> {"id":1,"firstName":"FirstName","name":"LastName"} |