Hello,
maybe i'm bad understand to json.Unmarshal and slices.
I've data in json: 
vals := 
`[{"time":"20160902","value":572736},{"time":"20160903","value":567616},{"time":"20160904","value":554560},{"time":"20160905","value":565600},{"time":"20160906","value":554752},{"time":"20160907","value":555744},{"time":"20160908","value":551392},{"time":"20160909","value":558272},{"time":"20160910","value":545696},{"time":"20160911","value":528032},{"time":"20160912","value":560960},{"time":"20160913","value":560480},{"time":"20160914","value":561920},{"time":"20160915","value":561216},{"time":"20160916","value":564512},{"time":"20160917","value":552352},{"time":"20160918","value":524960},{"time":"20160919","value":562688},{"time":"20160920","value":577632},{"time":"20160921","value":564704},{"time":"20160922","value":567296},{"time":"20160923","value":564544},{"time":"20160924","value":570944},{"time":"20160925","value":576224},{"time":"20160926","value":594176},{"time":"20160927","value":590784},{"time":"20160928","value":561184},{"time":"20160929","value":563744},{"time":"20160930","value":560928}]`

//Stucture for them is:
type tData struct{
    time string
    value float64
}

//And for location i've structure:
type tReport struct{
    //Siteid int
    Mname string
    Vals []tData
}

//I must Unmarshal data into tReport.Vals. Fragments of code:

var report []tReport
var dat []tData

if err := json.Unmarshal([]byte(vals), &dat); err != nil {
  ml.ErrInfo(err, verboseFlag)
}
fmt.Println("Data::")
fmt.Println(dat)
report = append(report, tReport{Mname: mname, Vals: nil})

//EOF code

But line fmt.Println(dat) shows me only: [{ 0} { 0} { 0} { 0} { 0} { 0} { 
0} { 0} { 0} { 0} { 0} { 0} { 0} { 0} { 0} { 0} { 0} { 0} { 0} { 0} { 0} { 
0} { 0} { 0} { 0} { 0} { 0} { 0} { 0}]

I don't understand why :-(.

Thank for Your help
  MaReK (MarekTP) Olsavsky

BTW: Sorry for terrible english, it's not my mature tongue.

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to