| 26 | } |
| 27 | |
| 28 | func ExampleEncode2() { |
| 29 | v1 := 23.5 |
| 30 | v2 := 23.6 |
| 31 | s := senml.SenML{ |
| 32 | Records: []senml.SenMLRecord{ |
| 33 | senml.SenMLRecord{Value: &v1, Unit: "Cel", BaseName: "urn:dev:ow:10e2073a01080063", Time: 1.276020076305e+09}, |
| 34 | senml.SenMLRecord{Value: &v2, Unit: "Cel", Time: 1.276020091305e+09}, |
| 35 | }, |
| 36 | } |
| 37 | |
| 38 | dataOut, err := senml.Encode(s, senml.JSON, senml.OutputOptions{}) |
| 39 | if err != nil { |
| 40 | fmt.Println("Encode of SenML failed") |
| 41 | } else { |
| 42 | fmt.Println(string(dataOut)) |
| 43 | } |
| 44 | // Output: [{"bn":"urn:dev:ow:10e2073a01080063","u":"Cel","t":1276020076.305,"v":23.5},{"u":"Cel","t":1276020091.305,"v":23.6}] |
| 45 | } |
| 46 | |
| 47 | type TestVector struct { |
| 48 | testDecode bool |