We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I don't think the following test is correct.
func (j *Json) Array() ([]interface{}, error) { if a, ok := (j.data).([]interface{}); ok { return a, nil
j.data is already an interface{} so it will never be an []interface{}.
j.data
[]interface{}
I think the correct test is:
func (j *Json) Array() ([]interface{}, error) { if reflect.TypeOf(j.data).Kind() == reflect.Array { v := reflect.ValueOf(j.data) a := make([]interface{}, v.Len()) for i := 0; i < v.Len(); i++ { a[i] = v.Index(i) } return a, nil
I will test this locally.
Please let me know if I misunderstand what you are doing here.
The text was updated successfully, but these errors were encountered:
Here is a test that fails with the current code.
a := [3]string{"one", "two", "three"} j := sjson.New() j.Set("myname", a) _, err = j.Get("myname").Array() if err != nil {fmt.Println(err)}
Sorry, something went wrong.
Turns out that Set() needed to be fixed and convert interface{} for arrays to []interface{}
No branches or pull requests
I don't think the following test is correct.
j.data
is already an interface{} so it will never be an[]interface{}
.I think the correct test is:
I will test this locally.
Please let me know if I misunderstand what you are doing here.
The text was updated successfully, but these errors were encountered: