You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, depending on circumstances arrays can be either Marshalled to JSON as null or []. It would be best if we send just one format, possibly the [].
The text was updated successfully, but these errors were encountered:
As a consumer of the HTTP API, I would greatly prefer to receive an empty array compared to null, since you don't really have to have any special logic, you just can treat it as an array while forEach with null would fail for example.
I agree that this would be preferable, but unfortunately I don't really know how to do that without either (a) initializing all nil slices to empty slices or (b) using custom types for all slices with MarshalJSON functions that encode nil values to '[]'. Both of these can not be fixed in this library, but on the code that determines which values to be sent (i.e. go-ipfs).
I'll try to find all instances in this package, though.
@keks I've filed a feature request to always encode slices/maps to [] and {} with refmt (a marshaling library we're planning on using for IPLD stuff): polydawn/refmt#25
If that works out, we can just replace the json library with that one.
Currently, depending on circumstances arrays can be either Marshalled to JSON as null or []. It would be best if we send just one format, possibly the [].
The text was updated successfully, but these errors were encountered: