From ebcb9f0bb588295c69a5abc6504f2faf94707901 Mon Sep 17 00:00:00 2001 From: athul Date: Thu, 30 Jan 2020 22:53:00 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=B1=20New=20Send=20Feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + methods/json.go | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) create mode 100644 methods/json.go diff --git a/.gitignore b/.gitignore index cb80d86..baf40be 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ # End of https://www.gitignore.io/api/go,visualstudiocode docs.md +.DS_Store diff --git a/methods/json.go b/methods/json.go new file mode 100644 index 0000000..a934c21 --- /dev/null +++ b/methods/json.go @@ -0,0 +1,56 @@ +//Colls hold the format of the basic `postwoman-collection.json` +type Colls struct { + Name string `json:"name"` + Folders []string `json:"folders"` + Request []Reqdata `json:"requests"` +} + +//Reqdata hold the format of the request part in `postwoman-collection.json` +type Reqdata struct { + URL string `json:"url"` + Path string `json:"path"` + Method string `json:"method"` + Auth string `json:"auth"` + User string `json:"httpUser"` + Pass string `json:"httpPassword"` + Token string `json:"bearerToken"` + Ctype string `json:"contentType"` + Heads []string `json:"headers"` + Params []string `json:"params"` + Bparams []Bpardata `json:"bodyParams"` +} + +//Bpardata hold the format of the bodyParams of `postwoman-collection.json` +type Bpardata struct { + Key string `json:"key"` + Value string `json:"value"` +} + +func main() { + data, err := ioutil.ReadFile("/Users/athul/Downloads/pwclc.json") + if err != nil { + fmt.Print(err) + } + //fmt.Print(string(data)) + jsondat := []Colls{} + + err = json.Unmarshal([]byte(data), &jsondat) + if err != nil { + fmt.Println(err) + } + //fmt.Println(jsondat) + //fmt.Print(jsondat[0].Name + "\n") + //fmt.Println(jsondat[0].Request[4].URL) + //fmt.Println(jsondat[0].Request[0].Method) + for i := 0; i < len(jsondat[0].Request); i++ { + fmt.Printf(` + URL: %s + Method: %s + Auth: %s + -------`, jsondat[0].Request[i].URL, jsondat[0].Request[i].Method, jsondat[0].Request[i].Auth) + } + +} +func request(){ + +} \ No newline at end of file