Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: set value is makred as obsolete #145

Merged
merged 2 commits into from
Aug 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading