Comments (7)
Enums are marshalled as strings per RFC7951: https://datatracker.ietf.org/doc/html/rfc7951#section-6.4
from ygot.
yes, thats right but my string value is 50, and failing while unmarshalling.
from ygot.
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 "50"
rather than 50
. I'm not immediately seeing how sanitizeJSON
could be the issue in any case assuming the leaf is an enum.
from ygot.
Hello, Sorry for late reply.
Suppose enum is defined as follow,
typedef example_enum {
type enumeration {
enum 25 { value 1; }
enum 50 { value 2; }
enum 75 { value 3; }
enum 100 { value 4; }
}
}
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"
from ygot.
Hi,
Could you provide the JSON input you're using? This sounds like you might have this field set as foo: 50
rather than foo: "50"
.
Thanks,
r.
from ygot.
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
from ygot.
Related Issues (20)
- ytypes.GetNode consumes more CPU & memory than the deprecated util.GetNode
- how to resolve the dependency for gribi HOT 2
- Diff api does generate deletes for leaf list values HOT 6
- Can enum preserve their defined values while converting yang to gostruct using openconfig/ygot\@v0.25.4/generator/generator.go ? HOT 3
- ygot.Diff don't respect presence containers HOT 9
- Mandatory module name in the generated struct names HOT 3
- Preserve YANG elements order when generating structs HOT 1
- Doesn't choice and case statement in YANG result in oneof fields in proto? HOT 2
- ygot Validate error, when yang leaf type is union
- When will ygot have support for bits datatype for yang to go conversion HOT 2
- Device Returns Array for Each Interface HOT 3
- Allow ytypes.SetNode on intermediate nodes in compressed mode
- Identity Support in Ygot HOT 1
- Union field has nil value after xml.Unmarshal HOT 6
- [Question] From ygot gostruct or emittedJSON to gNMI Set Update HOT 6
- How to set LeafrefOptions IgnoreMissingData for UnmarshalSetRequest HOT 2
- Can't generate OC-YANG network-instance HOT 2
- ResolveLeafrefTarget Not returning correct vlaue in case of List inside choice where list's key is a leafref HOT 2
- "default value not supported for wrapper union values" HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ygot.