Comments (3)
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.
You mean something like this:
Resources
|
| -- CollectionJsonResources
|
| -- JsonLdResources
|
\ -- JsonSchemaResources
Maybe with relevant builders/factories, something like:
buildLdResources(Object... objects)
from spring-hateoas.
Superceded by #482
from spring-hateoas.
Related Issues (20)
- Upgrade to Slf4j 2.0.7
- Upgrade to Spring Framework 6.1 M1
- Upgrade to Spring Framework 6.0.11
- Upgrade to Spring Framework 6.0.11
- Upgrade to Spring Framework 5.3.29
- Upgrade to Kotlin 1.8.22
- Switch to `UriComponentsBuilder.fromUri(…)`
- Release 1.5.5
- Switch to `UriComponentsBuilder.fromUri(…)`
- Release 2.0.5
- Switch to `UriComponentsBuilder.fromUri(…)`
- Release 2.1.1
- Release 2.2 M1
- Switch to `UriComponentsBuilder.fromUri(…)`
- Regression in AOT metadata generation
- Regression in AOT metadata generation
- Regression in AOT metadata generation
- Release 2.0.6
- Release 2.1.2
- Release 2.2 M2
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 spring-hateoas.