MCPcopy
hub / github.com/tidwall/gjson / TestUnmarshalMap

Function TestUnmarshalMap

gjson_test.go:778–795  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

776}`
777
778func TestUnmarshalMap(t *testing.T) {
779 var m1 = Parse(exampleJSON).Value().(map[string]interface{})
780 var m2 map[string]interface{}
781 if err := json.Unmarshal([]byte(exampleJSON), &m2); err != nil {
782 t.Fatal(err)
783 }
784 b1, err := json.Marshal(m1)
785 if err != nil {
786 t.Fatal(err)
787 }
788 b2, err := json.Marshal(m2)
789 if err != nil {
790 t.Fatal(err)
791 }
792 if !bytes.Equal(b1, b2) {
793 t.Fatal("b1 != b2")
794 }
795}
796
797func TestSingleArrayValue(t *testing.T) {
798 var json = `{"key": "value","key2":[1,2,3,4,"A"]}`

Callers

nothing calls this directly

Calls 2

ParseFunction · 0.85
ValueMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…