Closed an2deg closed 5 years ago
Hi!
I have the following JSON structure:
{"d":[{"author":{"displayName":"DemoUser3","id":2},"classes":null,"id":9879,"v":{"code":"","created":"2013-09-19T09:38:50+02:00","published":"0001-01-01T00:00:00Z","updated":"2013-09-19T09:38:50+02:00"}}],"s":200}
And method IsMSISlice() returns false. Test:
json, err := objx.FromJSON(`{"d":[{"author":{"displayName":"DemoUser3","id":2},"classes":null,"id":9879,"v":{"code":"","created":"2013-09-19T09:38:50+02:00","published":"0001-01-01T00:00:00Z","updated":"2013-09-19T09:38:50+02:00"}}],"s":200}`) if !assert.NoError(t, err, "Can't decode output") { return } assert.True(t, json.Has("d"), json.MustJSON()) if !assert.True(t, json.Get("d").IsMSISlice(), json.MustJSON()) { return } if !assert.Equal(t, 1, len(json.Get("d").MSISlice()), "...") { return }
The JSON unmarshaller unpacks all slices to []interface{}. To make it an MSI, I think we'd have to iterate and copy to the new slice.
Hi!
I have the following JSON structure:
And method IsMSISlice() returns false. Test: