Git Product home page Git Product logo

Comments (7)

ledsoft avatar ledsoft commented on May 24, 2024

Hi,
this behavior is intentional. JB4JSON-LD will try to find the most specific matching type and if there are multiple (D' and D'' in your case), the library cannot decide which one to use. Using the parent (D) is theoretically possible, but what if it is abstract, or an interface? In addition, if D is a concrete class, the JSON can contain attributes mapped by D' or D'' which in this case wouldn't match in D.
I suppose a configuration parameter could be used to override the default behavior in favor of using the parent, with the risk of loosing some attributes. In that case, a PR would be welcome.

from jb4jsonld.

ledsoft avatar ledsoft commented on May 24, 2024

I think the planned support for custom (de)serializers would help in this case as well. See #28

from jb4jsonld.

cristianolongo avatar cristianolongo commented on May 24, 2024

Honestlt It is quite common in the semantic web realm that a class has some subclasses not necessarily disjoint. So we have to think about a solution in which no exception is thrown in this case.

from jb4jsonld.

ledsoft avatar ledsoft commented on May 24, 2024

Fair enough. @psiotwo , what do you think?

from jb4jsonld.

psiotwo avatar psiotwo commented on May 24, 2024

but what if it is abstract, or an interface?

Good point. We can try to go higher in the hierarchy.

with the risk of loosing some attributes.

If D has unmapped properties, the additional D',D'' props should appear there.

I think it makes sense to support this parent resolution and a configuration parameter for using parents optimistically should be appropriate.

from jb4jsonld.

cristianolongo avatar cristianolongo commented on May 24, 2024

In this case one expect an object of class D, so returning an individual of any of its subclasses D' or D'' is good enough.

from jb4jsonld.

ledsoft avatar ledsoft commented on May 24, 2024

Implemented in 0.8.2. Configured via the enableOptimisticTargetTypeResolution and preferSuperclass parameters. Feel free to check it out and reopen (or report a new issue) if there are any problems.

from jb4jsonld.

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.