go
go copied to clipboard
No way to distinguish between "end of object" and field with blank name
func (iter *Iterator) ReadObject() (ret string)
ReadObject read one field from object. If object ended, returns empty string. Otherwise, returns the field name.
https://github.com/json-iterator/go/blob/71ac16282d122fdd1e3a6d3e7f79b79b4cc3b50e/iter_object.go#L40-L41
The problem with this is, there is, as far as I can tell, no way for the caller to distinguish between empty field names and end of object.
I guess it is not incredibly easy to fix this without breaking the API. One option is to provide some function for checking if the next input is end of array, or end of object, that way users can call that before calling ReadObject(...)
.
Maybe adding another function func (iter *Iterator) ReadObject() (hasMore bool, ret string)
can work?