protobuf icon indicating copy to clipboard operation
protobuf copied to clipboard

when Unmarshal a slice field, json str is '[]' or empty, the value is always nil.

Open JOHNKING123 opened this issue 3 years ago • 3 comments

when Unmarshal a slice field, json str is '[]' or empty, the value is always nil. i want to distinguish ,how can i do

JOHNKING123 avatar Aug 05 '21 07:08 JOHNKING123

Protobuf repeated fields don't have a concept of presence, so there is no distinction between a zero-length repeated field and an unset repeated field. I'm afraid there is no way for you to distinguish between these cases after unmarshaling.

neild avatar Aug 05 '21 17:08 neild

ok.thanks. There is such the scene. if you can give other suggests, i will be thankful.

JOHNKING123 avatar Aug 06 '21 10:08 JOHNKING123

ok.thanks. There is such the scene. if you can give other suggests, i will be thankful.

homelight/json This repo can help.

momopluto avatar Jan 17 '22 09:01 momopluto