From 643dfd92d0fb407f8329d6c5dfc75a9489731b89 Mon Sep 17 00:00:00 2001 From: Faizan Khalid Date: Sun, 13 Aug 2023 12:25:13 +0500 Subject: [PATCH] Updated README --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index b31ac89..26a6857 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ go get -u github.com/IamFaizanKhalid/jsonq ## Usage Example +See [reference docs](https://pkg.go.dev/github.com/IamFaizanKhalid/jsonq) for more details. + ```go package main @@ -47,21 +49,25 @@ func main() { } }`) + // parsing the JSON object resp, err := jsonq.ParseObject(apiResponse) if err != nil { panic(err) } + // getting values from the object code := resp.Val("code").Int() status := resp.Val("status").Str() fmt.Println(code, status) + // checking if the object contains the sub-object if !resp.Has("data") { return } data := resp.Obj("data") + // getting a sub-object which is optional userInfo, ok := data.OptObj("user") if ok { fmt.Println("-- User Info --") @@ -73,6 +79,7 @@ func main() { fmt.Println("-- Posts --") + // getting array of objects posts := data.Arr("posts").Obj() for _, post := range posts {