I have to format a json in go and I have some problems. the string literal that I have used in java is the following:
String jsonString= "{\"stream\":\"temperatura2\",\r\n" +
"\"sensor\":\"ec6c613a-66b4-4584-fb37-5f7cac130f7d\",\r\n" +
"\"values\":[{\"time\":\"2019-03-10T11:30:00Z\",\"components\":{\"alfanum\":\"99.0\"}}]}\r\n";
So I created this struct:
type YuccaDataStream struct {
Stream string `json:"stream"`
Sensor string `json:"sensor"`
Values []struct {
Time time.Time `json:"time"`
Components struct {
Alfanum string `json:"alfanum"`
} `json:"components"`
} `json:"values"`
}
Is that struct correct? I don't know how to create an instance of that struct and fill it with the current time.