Comments (5)
Hi there. Is there any update on this issue or the related #95 ?
My use-case requires creating a go JSON API server and client, meaning I will need to marshal and unmarshal the data. More specifically, I would like access to the "meta" for a relationship, which seems to be already supported for marshalling (see https://github.com/google/jsonapi/blob/master/node.go#L59).
My current options seem to be:
- Unmarshal twice, as @mitchellh has done. I believe that this would require a little work to map the data to the appropriate relationship.
- Unmarshal exclusively using
encoding/json
.
If anyone has any other potential workarounds, I'd be extremely grateful!
from jsonapi.
My use case is actually for a response, I'd like to extract that meta result. Currently I'm unmarshaling twice to get it since the tags don't support getting it directly.
from jsonapi.
The point of meta is to describe the response.. What's the point of submitting a request with meta to your api? If its a required field, it should be in attributes or another object? Not disagreeing, just wondering what the use-case is?
from jsonapi.
from jsonapi.
func setDataIntoTarget(data *Data, target interface{}) error {} is missing following chunk of code which will resolve meta part of unmarshaling
if data.Meta != nil {
err = json.Unmarshal(data.Meta, castedTarget)
if err != nil {
return err
}
}
from jsonapi.
Related Issues (20)
- Type validation on post is skipped
- Support for partial inclusion of relationships
- Asymmetrical behavior with json.RawMessage-type fields
- Community adoption of project HOT 4
- Unmarshall array of object in attribute HOT 1
- map inside struct unmarshalling HOT 2
- Export clearIncluded HOT 1
- got the wrong id when unmarshel a stract with an Int64 id HOT 1
- Is this project active? HOT 4
- Polymorphic relationships HOT 1
- Skipping an element in an array due to unmatched type
- Does example in README have a typo? HOT 1
- int64 id value changed while decoding HOT 12
- Marshal nested object does not work
- data is not a jsonapi representation of *type HOT 2
- Support for Unmarshalling Slices of floats/ints/bools
- Empty relation atrributes HOT 1
- adding meta at time of encoding
- jsonapi.MarshalPayload sets response status to 200, but I want 201 (created) HOT 1
- The wiki shows some weird 'hack' text
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 jsonapi.