Skip to content

Commit

Permalink
Merge pull request #145 from microsoft/bugfix/set-value
Browse files Browse the repository at this point in the history
fix: set value is makred as obsolete
  • Loading branch information
baywet authored Aug 13, 2024
2 parents 51cb99b + 8b97c2b commit 3c22849
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions json_parse_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ func loadJsonTree(decoder *json.Decoder) (*JsonParseNode, error) {
i, err := number.Int64()
c := &JsonParseNode{}
if err == nil {
c.SetValue(&i)
c.setValue(&i)
} else {
f, err := number.Float64()
if err == nil {
c.SetValue(&f)
c.setValue(&f)
} else {
return nil, err
}
Expand All @@ -101,42 +101,42 @@ func loadJsonTree(decoder *json.Decoder) (*JsonParseNode, error) {
case string:
v := token.(string)
c := &JsonParseNode{}
c.SetValue(&v)
c.setValue(&v)
return c, nil
case bool:
c := &JsonParseNode{}
v := token.(bool)
c.SetValue(&v)
c.setValue(&v)
return c, nil
case int8:
c := &JsonParseNode{}
v := token.(int8)
c.SetValue(&v)
c.setValue(&v)
return c, nil
case byte:
c := &JsonParseNode{}
v := token.(byte)
c.SetValue(&v)
c.setValue(&v)
return c, nil
case float64:
c := &JsonParseNode{}
v := token.(float64)
c.SetValue(&v)
c.setValue(&v)
return c, nil
case float32:
c := &JsonParseNode{}
v := token.(float32)
c.SetValue(&v)
c.setValue(&v)
return c, nil
case int32:
c := &JsonParseNode{}
v := token.(int32)
c.SetValue(&v)
c.setValue(&v)
return c, nil
case int64:
c := &JsonParseNode{}
v := token.(int64)
c.SetValue(&v)
c.setValue(&v)
return c, nil
case nil:
return nil, nil
Expand All @@ -146,8 +146,13 @@ func loadJsonTree(decoder *json.Decoder) (*JsonParseNode, error) {
return nil, nil
}

// SetValue sets the value represented by the node
// SetValue is obsolete, parse nodes are not meant to be settable externally
func (n *JsonParseNode) SetValue(value interface{}) {
n.setValue(value)
}

// setValue sets the value represented by the node
func (n *JsonParseNode) setValue(value interface{}) {
n.value = value
}

Expand Down

0 comments on commit 3c22849

Please sign in to comment.