A
A
Andrey2017-03-16 14:41:12
go
Andrey, 2017-03-16 14:41:12

How to work with JSON of arbitrary structure?

I have json like this:

{
  "properties_1": {
    "key_1": "value 1",
    "key_2": "value 2",
    "key_3": "value 3",
    "key_4": "value 4",
    "key_5": "value 5"
  },
  "properties_2": {
    "key_1": "value 1",
    "key_2": 1000,
    "key_3": 47.595,
    "key_4": "7006"
  },
  "ProductID": "7575",
  "DateTime": "2000-01-01 00:00:00",
}

how to get some data structure suitable for processing in go?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
rustler2000, 2017-03-16
@rustler2000

https://blog.golang.org/json-and-go @Decoding arbitrary data

K
kolo2012, 2017-03-16
@kolo2012

like this json2struct.mervine.net
And in order for everything to work, json must be valid, in your case

{
  "properties_1": {
    "key_1": "value 1",
    "key_2": "value 2",
    "key_3": "value 3",
    "key_4": "value 4",
    "key_5": "value 5"
  },
  "properties_2": {
    "key_1": "value 1",
    "key_2": 1000,
    "key_3": 47.595,
    "key_4": "7006"
  },
  "ProductID": "7575",
  "DateTime": "2000-01-01 00:00:00"
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question