MCPcopy Index your code
hub / github.com/cisco/senml / ExampleEncode1

Function ExampleEncode1

senml_test.go:11–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

9)
10
11func ExampleEncode1() {
12 v := 23.1
13 s := senml.SenML{
14 Records: []senml.SenMLRecord{
15 senml.SenMLRecord{Value: &v, Unit: "Cel", Name: "urn:dev:ow:10e2073a01080063"},
16 },
17 }
18
19 dataOut, err := senml.Encode(s, senml.JSON, senml.OutputOptions{})
20 if err != nil {
21 fmt.Println("Encode of SenML failed")
22 } else {
23 fmt.Println(string(dataOut))
24 }
25 // Output: [{"n":"urn:dev:ow:10e2073a01080063","u":"Cel","v":23.1}]
26}
27
28func ExampleEncode2() {
29 v1 := 23.5

Callers

nothing calls this directly

Calls 1

EncodeFunction · 0.92

Tested by

no test coverage detected