How to create a JSON array
Opened this issue · 3 comments
Desired results:
[{"id":"1","name":"test"}]
Results obtained now:
[{"id":"1","name":"test"},{"id":"1","name":"test"}]
code
jsonArray := gabs.New() jsonArray.Set("1", "id") jsonArray.Set("test", "name") jsonArray.ArrayAppend(jsonArray.Data())
No relevant information was found. Please share a solution
mainObj := gabs.New()
subObj := gabs.New()
subObj.Set("1", "id")
subObj.Set("test", "name")
mainObj.Array()
mainObj.ArrayAppend(subObj.Data())
mainObj := gabs.New()
subObj := gabs.New() subObj.Set("1", "id") subObj.Set("test", "name")
mainObj.ArrayAppend(subObj.Data())
Use the method you said to execute the results :[{},{"id":"1","name":"test"}]
More {},Is there a way to remove it
mainObj := gabs.New()
subObj := gabs.New() subObj.Set("1", "id") subObj.Set("test", "name")
mainObj.ArrayAppend(subObj.Data())
Use the method you said to execute the results :[{},{"id":"1","name":"test"}]
More {},Is there a way to remove it
I forgot the .Array()
Example has been updated.