Skip to content

Instantly share code, notes, and snippets.

@MattOates
Last active December 20, 2015 23:09
Show Gist options
  • Save MattOates/6210682 to your computer and use it in GitHub Desktop.
Save MattOates/6210682 to your computer and use it in GitHub Desktop.
package main
import(
"fmt"
"net/http"
"net/url"
"io/ioutil"
"encoding/json"
//"strings"
)
func main() {
request, err := http.PostForm("http://d2p2.pro/api/seqid",url.Values{"seqids":{"[\"P04637\"]"}})
if err != nil {
// handle error
}
defer request.Body.Close()
body, err := ioutil.ReadAll(request.Body)
var response map[string]json.RawMessage
json.Unmarshal(body, &response)
var response1 []json.RawMessage
json.Unmarshal(response["P04637"], &response1)
var response2 []json.RawMessage
json.Unmarshal(response1[0], &response2)
var response3 map[string]json.RawMessage
json.Unmarshal(response2[2], &response3)
var response4 map[string]json.RawMessage
json.Unmarshal(response3["disorder"], &response4)
var response5 [][]string
json.Unmarshal(response4["disranges"], &response5)
for _,record := range response5 {
for _,field := range record {
fmt.Printf("%s\t", field)
}
fmt.Printf("\n")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment