Comments (3)
Here is the jsonapi body:
{
"jsonapi": {
"version": "1.0",
"meta": {
"links": {
"self": {
"href": "http://jsonapi.org/format/1.0/"
}
}
}
},
"data": [
{
"type": "account--bank_account",
"id": "redacted",
"links": {
"self": {
"href": "redacted"
}
},
"attributes": {
"drupal_internal__id": 1,
"name": "redacted",
"status": true,
"field_balance": 0,
"field_hidden": false,
"field_weight": 0
},
"relationships": {
"field_account_status": {
"data": {
"type": "taxonomy_term--account_status",
"id": "redacted",
"meta": {
"drupal_internal__target_id": 1
}
},
"links": {
"related": {
"href": "redacted"
},
"self": {
"href": "redacted"
}
}
},
"field_account_type": {
"data": {
"type": "taxonomy_term--account_type",
"id": "redacted",
"meta": {
"drupal_internal__target_id": 1
}
},
"links": {
"related": {
"href": "redacted"
},
"self": {
"href": "redacted"
}
}
},
"field_currency": {
"data": {
"type": "taxonomy_term--currency",
"id": "redacted",
"meta": {
"drupal_internal__target_id": 1
}
},
"links": {
"related": {
"href": "redacted"
},
"self": {
"href": "redacted"
}
}
}
}
}
],
"included": [
{
"type": "taxonomy_term--account_status",
"id": "redacted",
"links": {
"self": {
"href": "redacted"
}
},
"attributes": {
"drupal_internal__tid": 1,
"status": true,
"name": "Active",
"description": null,
"weight": 0
}
},
{
"type": "taxonomy_term--account_type",
"id": "redacted",
"links": {
"self": {
"href": "redacted"
}
},
"attributes": {
"drupal_internal__tid": 1,
"status": true,
"name": "Deposit",
"description": null,
"weight": 0
}
},
{
"type": "taxonomy_term--currency",
"id": "redacted",
"links": {
"self": {
"href": "redacted"
}
},
"attributes": {
"drupal_internal__tid": 1,
"status": true,
"name": "redacted",
"description": null,
"weight": 1,
"field_currency_code": "redacted"
}
}
],
"links": {
"first": {
"href": "redacted"
},
"next": {
"href": "redacted"
},
"prev": {
"href": "redacted"
},
"self": {
"href": "redacted"
}
}
}
from jsonapi.
It is not possible to pass in plain Document
type since Document<T>
is generic.
For example, if you have a document of an article (standard example) it is not possible to pass the type of the Document
like this
val type = Document::class.java
Nor you can do
val type = Article::class.java
Instead, you need to pass parameterized type
// Create a type for Document<Article>
val type = Types.newParameterizedType(Document::class.java, Article::class.java)
val articleAdapter: JsonAdapter<Document<Article>> = moshi.adapter(type)
In case you have a collection of articles then you can do it like this:
// Create a type for Document<List<Article>>
val type = Types.newParameterizedType(Document::class.java, Types.newParameterizedType(List::class.java, Article::class.java))
val articleAdapter: JsonAdapter<Document<List<Article>>> = moshi.adapter(type)
from jsonapi.
Thanks for your help, I've gotten things working
from jsonapi.
Related Issues (11)
- Relationship are ignored when targets are not included HOT 6
- Problem creating error document HOT 1
- can't parse back from JSON HOT 4
- Atomic Operations support
- I think this need to be fixed HOT 3
- Moshi Codegen HOT 1
- Serialize collection of resources HOT 2
- Possible to decouple Moshi? HOT 1
- Serialize Null values HOT 3
- Incremental annotation processor HOT 4
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.