-
Notifications
You must be signed in to change notification settings - Fork 124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Please let me know how can I make models for mentioned json #281
Comments
Have a look at the configuration instruction, especially in the section beginning with "Then set up your models". For example, your model would start like this: // some imports
// ...
@JsonApiModelConfig({
type: 'tenants'
})
export class Tenant extends JsonApiModel {
@Attribute()
name: string;
@Attribute({ serializedName: 'created_by_user_id' })
createdByUserId: number;
// ...
} |
This is what I have made but please pay attention toward data object @JsonApiModelConfig({ })
} |
This will not work because the response of your server is not JSON:API conform: https://jsonapi.org/format/#document-top-level. So you only have two possibilities:
I would go with the solution 1. But if this is not feasible for you, you can use a HttpInterceptor and modify the response:
You should be aware, that this will intercept all your http requests. So make sure to handle that. Some remark to your model config: It may be a problem that your attributes have underscores instead of camelCase (see #86). If this is the case try to use it this way: @Attribute({ serializedName: 'created_by_user_id' })
createdByUserId: number; |
Thank you so much for your help |
@shantanugupta135 , nice to hear :) Would you mind closing this issue then? Thanks! |
{
"data": [
{
"data": {
"type": "tenants",
"id": "3c3a6031-eff9-4b8b-9d8c-2a1dfc86548e",
"attributes": {
"name": "thyssenkrupp AG",
"created_by_user_id": 1,
"updated_by_user_id": null,
"deleted_by_user_id": null,
"created_at": "2020-12-28T10:48:50.000000Z",
"updated_at": null
},
"links": {
"self": ""
}
}
}
The text was updated successfully, but these errors were encountered: