You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Key order is undefined in JSON and, because Go uses maps to hold JSON objects, the order will not be preserved. Details here: golang/go#27179. When marshalling to string, the keys will be sorted lexicographically:
Map values encode as JSON objects. The map's key type must either be a string, an integer type, or implement encoding.TextMarshaler. The map keys are sorted and used as JSON object keys by applying the following rules, subject to the UTF-8 coercion described for string values above:
keys of any string type are used directly
encoding.TextMarshalers are marshaled
integer keys are converted to strings
package main
import (
"fmt"
"github.com/Jeffail/gabs"
)
func main() {
jsonStr :=
{"b":"dddd","a":"111"}
d, _ := gabs.ParseJSON([]byte(jsonStr))
fmt.Println(d.String())
}
// output {"a":"111","b":"dddd"} how to get result : {"b":"dddd","a":"111"} ???
The text was updated successfully, but these errors were encountered: