123456789101112131415161718192021222324252627282930313233343536 |
- package yu_json
- import "testing"
- func TestGet(t *testing.T) {
- json := `{
- "programmers": [
- {
- "firstName": "Janet",
- "lastName": "McLaughlin",
- }, {
- "firstName": "Elliotte",
- "lastName": "Hunter",
- }, {
- "firstName": "Jason",
- "lastName": "Harold",
- }
- ]
- }`
- value := Get(json, "name.last")
- println(value.String())
- value = Get(json, "programmers.#.lastName")
- println(value.String())
- for _, name := range value.Array() {
- println(name.String())
- }
- value = Get(json, "age")
- println(value.String())
- println(json)
- }
|