gabs icon indicating copy to clipboard operation
gabs copied to clipboard

How to create a JSON array

Open carefree666 opened this issue 3 years ago • 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

carefree666 avatar Aug 27 '22 11:08 carefree666

mainObj := gabs.New()

subObj := gabs.New() subObj.Set("1", "id") subObj.Set("test", "name")

mainObj.Array() mainObj.ArrayAppend(subObj.Data())

buzzy avatar Aug 30 '22 15:08 buzzy

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

carefree666 avatar Sep 13 '22 11:09 carefree666

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.

buzzy avatar Sep 13 '22 11:09 buzzy