Git Product home page Git Product logo

Comments (3)

jbrisbin avatar jbrisbin commented on June 8, 2024

I would be hesitant to get behind any one JSON structure spec right now because there are several good contenders and each of them has something good in them (though I find all of them generally lacking in balance...e.g. they solve one problem well at the expense of others).

I don't really like this structure for JSON because it is, IMO, unnecessarily verbose. It combines a schema-like structure definition with the actual data, which I don't think is a good idea and too similar to XML, which is proven to be very prone to overuse and overkill. The "templates" here are an attempt to separate the structure of the document with its data, but even using a template one still has to include elements of a structural definition in the data (e.g. {"name": "propertyName", "value": "some value"}). It's not a clean separation between the data and the template.

JSON Schema is actually much cleaner in that regard. It separates the description of the structure of the document with its actual data. Being able to externally define a document is beneficial in a large set of use cases, particularly if you are generating forms, or otherwise creating helpers that want to interact with the expected data. It's also possible to mix-in document structures for a very flexible schema. I can't see that being possible with the static nature of the Collection+JSON approach.

So far as I could see, this solution also doesn't address linking of data (providing a links property isn't really what I'm talking about here). JSON-LD does address this, although it also has peculiarities that one might find annoying in real use. Of particular note in JSON-LD is the "context" of a node. Being able to namespace a JSON document would be very, very useful.

IMO a balanced approach would be to take something like JSON Schema (but with far fewer variances on the types of nodes within a schema to make parsers and validators far easier to write) and combine that with a JSON-LD type linking schema.

It may be that HATEOAS needs to provide Resource as a marker interface and provide implementations that are structured differently based on these various specs.

from spring-hateoas.

rgladwell avatar rgladwell commented on June 8, 2024

You mean something like this:

Resources
 |
 | -- CollectionJsonResources
 |
 | -- JsonLdResources
 |
 \ -- JsonSchemaResources

Maybe with relevant builders/factories, something like:

buildLdResources(Object... objects)

from spring-hateoas.

gregturn avatar gregturn commented on June 8, 2024

Superceded by #482

from spring-hateoas.

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.