Skip to content

Set operator with not expected behavior #97

@PeerXu

Description

@PeerXu

create map by FromJSON or New(with map[string]interface{}), and Set with fields got the difference result.

m := objx.FromJSON(`{"a": {"b": 1}}`)
m.Set("a.c", 2)
fmt.Println(m.JSON())  // output: {"a": {"c": 2}}
m := objx.New(map[string]interface{}{
  "a": map[string]interface{}{
    "b": 1,
  },
})
m.Set("a.c", 2)
fmt.Println(m.JSON())  // output: {"a": {"b": 1, "c": 2}}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions