I have tried the following with flattened JSON data like
`
flattenedData := map[string]interface{}{
"foo.arr.0": "apple",
"foo.arr.1": "banana",
"oarr.0.id": "id1",
"oarr.1.id": "id2",
}
// Create a new gabs container
container := gabs.New()
// Iterate through the flattened data and set values in the container
for path, value := range flattenedData {
container.SetP(value, path)
}
// Print the nested JSON as a string
fmt.Println(container.StringIndent("", " "))
`
I get
{ "foo": { "arr": { "0": "apple", "1": "banana" } }, "oarr": { "0": { "id": "id1" }, "1": { "id": "id2" } } }
Instead of
{ "foo": { "arr": [ "apple", "banana"] "oarr": [ { "id": "id1" }, { "id": "id2" } ] }
Is there a known way on how I can load this flattened data back into the container? It is using my array indexes as map keys right now.
I have tried the following with flattened JSON data like
`
flattenedData := map[string]interface{}{
"foo.arr.0": "apple",
"foo.arr.1": "banana",
"oarr.0.id": "id1",
"oarr.1.id": "id2",
}
`
I get
{ "foo": { "arr": { "0": "apple", "1": "banana" } }, "oarr": { "0": { "id": "id1" }, "1": { "id": "id2" } } }Instead of
{ "foo": { "arr": [ "apple", "banana"] "oarr": [ { "id": "id1" }, { "id": "id2" } ] }Is there a known way on how I can load this flattened data back into the container? It is using my array indexes as map keys right now.