Code Monkey home page Code Monkey logo

Comments (7)

wenovus avatar wenovus commented on September 26, 2024

Enums are marshalled as strings per RFC7951: https://datatracker.ietf.org/doc/html/rfc7951#section-6.4

from ygot.

ruchakulkarni11 avatar ruchakulkarni11 commented on September 26, 2024

yes, thats right but my string value is 50, and failing while unmarshalling.

from ygot.

wenovus avatar wenovus commented on September 26, 2024

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.

ruchakulkarni11 avatar ruchakulkarni11 commented on September 26, 2024

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.

robshakir avatar robshakir commented on September 26, 2024

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.

ruchakulkarni11 avatar ruchakulkarni11 commented on September 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.