I can't use golang to parse this json with server response:
{
"id": 1,
"description": "{\"uDes\":\"\",\"reDes\":[{\"des\":\"aaa,,request=<?xml version=“1.0“ encoding=“GBK“?><Req ver=“3.0“><HR version=“3.0“ cd=“0“><src><\\\\/src><license><\\\\/license><clientid>com.sample.xo<\\\\/clientid><ii>8603<\\\\/ii><im>46002910<\\\\/im><uuid>da032b2<\\\\/uuid><reqid>-21851<\\\\/reqid><smc>44:91<\\\\/smc><sdv>2.0.201501131131.a.r<\\\\/sdv><corv>V1.1.0r<\\\\/corv><\\\\/HDR><DRR nettype=“LTE“ inftype=“1“><mc>460<\\\\/cc><mnc>00<\\\\/mnc><lac>34809<\\\\/lac><cellid>8842241<\\\\/cellid><signal>-69<\\\\/signal><\\\\/DRR><\\\\/Cell_Req>&retype=3×tamp=1469550331136\"}]}"
}
please note the key 'description' has a lot of illegal character.I just want to get and store it as a string into our database. the go code fragment following:
import (
"fmt"
"net/http"
"encoding/json"
)
var p := fmt.Println
type DataSlice struct{
Id int
Destription string
}
func main() {
p("Start fetching data..")
resp,err := http.Get("http://127.0.0.1/pis")
if err != nil{
//handle error
p(err)
}else{
defer resp.Body.Close()
var jsonInst DataSlice
p("Start decode json body..")
err := json.NewDecoder(resp.Body).Decode(&jsonInst)
if err != nil {
panic(err)
}else{
//do insert here
}
}
}
this code execute fine,but the description value is empty.please help me to resolve this problem. Thanks a lot!