-
Notifications
You must be signed in to change notification settings - Fork 107
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
ytypes.Unmarshal() treating 50 as a float64 even though I am converting 50 to string before unmarshalling #972
Comments
Enums are marshalled as strings per RFC7951: https://datatracker.ietf.org/doc/html/rfc7951#section-6.4 |
yes, thats right but my string value is 50, and failing while unmarshalling. |
Can you provide your YANG schema as well as a reproducing example? I have to go for today but I can take a look with those information when I get a chance. I'm not quite sure what you mean by the string value is 50. This means the JSON needs to be |
Hello, Sorry for late reply. Suppose enum is defined as follow,
Now here when enum index 2 is converted to name, its 50. Here enum name is string so 50 must be of type string, but the ytypes.Unmarshal returns error as "got float64 type for field, expect string" |
Hi, Could you provide the JSON input you're using? This sounds like you might have this field set as Thanks, |
If I set foo: "50", unmarshalling fails because "50" does not match with the enum-name 50. ytypes.Unmarshal: "50" is not a valid value for enum field Id |
Can you provide both the JSON and the YANG module? It's important how the leaf is defined to be able to debug this. |
I have an enum with index 1 and value 50. schema required to convert the enum index to enum value (string).
I am converting 50 to string type but while ytypes.Unmarshal() sanitizeJson method is treating 50 as a float64 even though I am converting 50 to string before unmarshalling.
Is there any way I can convert the type of 50 to string?
I would appreciate any inputs!
The text was updated successfully, but these errors were encountered: