-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
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
Empty string element in a slice disappears after decoding #105
Comments
Can you please provide a full code sample to reproduce this?
… On May 16, 2018, at 04:18, Maria Efimenko ***@***.***> wrote:
For example, I have a struct:
type Post struct { Images []string }
If I want to put in the struct values like (contains three elements, including empty string):
["a", "", ""b]
After decoding I have a slice with two elements excluding an empty string as a result.
Could you please tell me if it Is a bug or a way it works? Thank you!
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub <#105>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AADk-ubU3UQmTlNi6a_vNZR0CgS-n4HHks5tzAsWgaJpZM4UBHkr>.
|
|
Hi @mariaefi29 Sorry for taking a while back to you. What you need to do is call |
Thank you very much for your help! |
Hello! For me ZeroEmpty still not working. I still get an empty string instead of nil Here is my code: |
The zero value in Go for a string is “”. You may want [][]byte instead, if
dealing with image data.
…On Tue, Apr 9, 2019 at 2:43 AM novikov1337danil ***@***.***> wrote:
Hi @mariaefi29 <https://github.com/mariaefi29>
Sorry for taking a while back to you. What you need to do is call
decoder.ZeroEmpty(true) before calling the Decode method. That will cause
empty strings to produce the zero value of the decoded type, otherwise they
are ignored.
Hello! For me ZeroEmpty still not working. I still get an empty string
instead of nil
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#105 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AABIcLwXTMGD67edIPQJt41R5NEoE98Lks5vfGDZgaJpZM4UBHkr>
.
|
For example, I have a struct:
type Post struct { Images []string }
If I want to put in the struct values like (contains three elements, including empty string):
["a", "", "b"]
After decoding I have a slice with two elements excluding an empty string as a result.
Could you please tell me if it Is a bug or a way it works? Thank you!
The text was updated successfully, but these errors were encountered: