infinum / flutter-plugins-japx

JSON API parser for Flutter

Home Page:https://pub.dev/packages/japx

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nested JSON is not getting parsed

agarwalrohit2503 opened this issue · comments

The mentioned json is not getting parsed using the package but deserialize-json package in ReactJS is able to parse it
Please look into this and help me get a solution

{
"data": [
{
"id": "1090",
"type": "user",
"attributes": {
"display_name": "Ram Singh",
"username": "ram_singh",
"is_followed": true,
"is_requested": false,
"dp_url": null,
"dp_thumbnail": null,
"can_accept": null
},
"relationships": {
"user_profile": {
"data": {
"id": "716",
"type": "user_profile"
}
},
"generated_feeds": {
"data": [
{
"id": "19421",
"type": "story_feed"
}
]
}
}
}
],
"included": [
{
"id": "716",
"type": "user_profile",
"attributes": {
"privacy_level": "privat3",
"first_name": null,
"last_name": null,
"is_verified": false,
"market_view": "neutral",
"bio": "-"
}
},
{
"id": "3390",
"type": "attachment",
"attributes": {
"name": "media_files",
"record_type": "Story",
"record_id": 1139,
"blob": {
"id": 3390,
"key": "dasdasd",
"filename": "photo-sadads-d68292c34b19.jpeg",
"content_type": "image/jpeg",
"metadata": {
"identified": true,
"width": 801,
"height": 1200,
"analyzed": true
},
"byte_size": 125574,
"checksum": "asdsa==",
"created_at": "2023-09-29T13:54:03.110+05:30",
"service_name": "amazon",
"attachable_sgid": "XXXXX"
},
"key": "mgx4yrm7x9senrj7tjst0jh35rfi",
"file_path": "XXXXXXX",
"file_type": "image/jpeg"
}
},
{
"id": "3391",
"type": "attachment",
"attributes": {
"name": "media_files",
"record_type": "Story",
"record_id": 1139,
"blob": {
"id": 3391,
"key": "XXXXX",
"filename": "IMG_20230908_155020.jpg",
"content_type": "image/jpeg",
"metadata": {
"identified": true,
"width": 900,
"height": 1200,
"analyzed": true
},
"byte_size": 19478,
"checksum": "XXXX==",
"created_at": "2023-09-29T13:54:03.119+05:30",
"service_name": "amazon",
"attachable_sgid": "XXXX"
},
"key": "q2d4vslbodymdeyn94jfxufrcht4",
"file_path": "/XXXX",
"file_type": "image/jpeg"
}
},
{
"id": "3392",
"type": "attachment",
"attributes": {
"name": "media_files",
"record_type": "Story",
"record_id": 1139,
"blob": {
"id": 3392,
"key": "XXX",
"filename": "pexels-pixabay-268533.jpg",
"content_type": "image/jpeg",
"metadata": {
"identified": true,
"width": 1200,
"height": 799,
"analyzed": true
},
"byte_size": 71428,
"checksum": "CCCC/QfkRHGrwA==",
"created_at": "2023-09-29T13:54:03.125+05:30",
"service_name": "amazon",
"attachable_sgid": "CcCc--2a06d6e5ddd495cd4069b78fc7c50ba5afedda23"
},
"key": "pxggs6sovg9ztw84t7lokf48yyys",
"file_path": "/rpexels-pixabay-268533.jpg",
"file_type": "image/jpeg"
}
},
{
"id": "1090",
"type": "user",
"attributes": {
"display_name": "Mritunjay Singh",
"username": "mritunjay_singh",
"is_followed": true,
"is_requested": false,
"dp_url": null,
"dp_thumbnail": null,
"can_accept": null
},
"relationships": {
"user_profile": {
"data": {
"id": "716",
"type": "user_profile"
}
}
}
},
{
"id": "1139",
"type": "story",
"attributes": {
"message": null,
"visibility": "followers_visible",
"created_at": "2023-09-29T13:54:03.102+05:30",
"updated_at": "2023-09-29T13:54:03.130+05:30",
"meta_info": {
"text_color": "#000aaa",
"bg_color": "#000fff"
},
"likes_count": null,
"widgets_data": null,
"is_liked": false,
"is_deleted": false,
"views_count": 10
},
"relationships": {
"user": {
"data": {
"id": "1090",
"type": "user"
}
},
"poll": {
"data": null
},
"attachments": {
"data": [
{
"id": "3390",
"type": "attachment"
},
{
"id": "3391",
"type": "attachment"
},
{
"id": "3392",
"type": "attachment"
}
]
},
"media_files": {
"data": [
{
"id": "3390",
"type": "media_files"
},
{
"id": "3391",
"type": "media_files"
},
{
"id": "3392",
"type": "media_files"
}
]
},
"tagged_users": {
"data": []
},
"tagged_topics": {
"data": []
},
"tagged_instruments": {
"data": []
}
}
},
{
"id": "593",
"type": "user",
"attributes": {
"display_name": "Rohit Agarwal",
"username": "rohit_agarwal_ce22",
"is_followed": false,
"is_requested": false,
"dp_url": null,
"dp_thumbnail": null,
"can_accept": null
},
"relationships": {
"user_profile": {
"data": {
"id": "444",
"type": "user_profile"
}
}
}
},
{
"id": "19421",
"type": "story_feed",
"attributes": {
"read_at": null,
"viewer_id": 593,
"created_at": "2023-09-29T13:54:03.417+05:30",
"updated_at": "2023-09-29T13:54:03.417+05:30"
},
"relationships": {
"viewer": {
"data": {
"id": "593",
"type": "user"
}
},
"story": {
"data": {
"id": "1139",
"type": "story"
}
}
}
}
]
}

The above JSON does not give all the referenced or linked parts only links the user profile, but if we mention the "generated_feeds" in the includedList it links the list of generated_feeds but again it does not links user,story,attachements to it

Kindly if anyone has a solution then let me know
using the latest version of the package. japx: ^2.1.0 with Flutter version 3.13.x

@carr @nixa @bjosip @spoler Can you please look into this.?

Hi @Truba are u looking into this.?

Hi @agarwalrohit2503
You can specify multiple relationships in the includeList parameter. Use a , to add more relationships.
In your case it might look something this:

Japx.decode(jsonApi, includeList: `user_profile,generated_feeds.viewer,generated_feeds.story.attachments`);