Giter VIP home page Giter VIP logo

Comments (8)

sapek avatar sapek commented on August 19, 2024

Text protocols like JSON and Xml don't support bonded<T>. This is because the implementation uses streaming parsers (for better performance) which can't be cloned. bonded<T> has lazy deserialization semantics which means that during deserialization of the containing structure it needs to make a clone of the protocol in order to deserialize from it later. It will work if you change your schema to:

struct Record
{
    0: string Name;
    1: vector<double> Constants;
    2: InnerStruct data;
}

from bond.

SergeyKanzhelev avatar SergeyKanzhelev commented on August 19, 2024

What I want to achieve is to parse InnerStruct's baseType field and than apply proper deserializer to it. Is it possible with Json parser?

Schema like this:

namespace Examples
struct InnerStruct
{
    10: optional string baseType;
};
struct InnerStruct1: InnerStruct
{
    10: optional string baseType;
    20: string newField1;
};
struct InnerStruct2 : InnerStruct
{
    10: optional string baseType;
    20: string newField2;
};
struct Record
{
    0: string Name;
    1: vector<double> Constants;
    2: optional InnerStruct data;
};

from bond.

sapek avatar sapek commented on August 19, 2024

No, today polymorphism is not supported with JSON or Xml.

from bond.

SergeyKanzhelev avatar SergeyKanzhelev commented on August 19, 2024

Do you have it in plans? Is there a way to implement it using any sort of extensibility bond provides?

from bond.

sapek avatar sapek commented on August 19, 2024

We intend to support it but we are still investigating what the best approach is.

One option, which could be implemented using Bond extensibility mechanisms, is to implement JSON protocol using a DOM parser. This would require a new parser functionally equivalent to SimpleJsonParser (although probably simpler because stream parsing it more difficult). This is how polymorphism works with JSON in the C++ implementation.

from bond.

SergeyKanzhelev avatar SergeyKanzhelev commented on August 19, 2024

@abaranch for information.

@sapek we need a tool to parse Application Insights events which are bond-schema JSON in our tests. We are using custom tool to generate those parsers, but would really like to use something official, at least for functional tests. Can you please keep us posted on this work

from bond.

wasker avatar wasker commented on August 19, 2024

That be very nice to have this addressed.

from bond.

alexmg avatar alexmg commented on August 19, 2024

👍 Agreed. It would be nice to see this implemented.

from bond.

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.