infinum / flutter-plugins-japx Goto Github PK
View Code? Open in Web Editor NEWJSON API parser for Flutter
Home Page: https://pub.dev/packages/japx
License: MIT License
JSON API parser for Flutter
Home Page: https://pub.dev/packages/japx
License: MIT License
Have added the json file
Please look into this
Array relationships (one-many) that are part of the "included" field have their items set as null when they themselves are not included in the server response. For example:
{
{
"data": {
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!",
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z"
},
"relationships": {
"author": {
"data": {"id": "42", "type": "people"}
}
}
},
"included": [
{
"type": "people",
"id": "42",
"attributes": {
"name": "John",
"age": 80,
"gender": "male"
},
"relationships": {
"article": {
"data": {"id": "1", "type": "articles"}
},
"categories" : {
"data" : [
{"id": "1", "type": "categories"}
]
}
}
}
]
}
Here relationships.article
will be correctly parsed and shown, but categories.data
will be set to a array with all its items in null (it won't even be an empty array, breaking applications on some server responses).
The expected output is:
{
"data": {
"type": "articles",
"id": "1",
"title": "JSON API paints my bikeshed!",
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z",
"author": {
"type": "people",
"id": "42",
...
"categories": [
{
"type": "categories",
"id": "1"
}
],
"article": { ... }
}
}
}
The actual output is
{
"data": {
"type": "articles",
"id": "1",
"title": "JSON API paints my bikeshed!",
"body": "The shortest article. Ever.",
"created": "2015-05-22T14:56:29.000Z",
"updated": "2015-05-22T14:56:28.000Z",
"author": {
"type": "people",
"id": "42",
...
"categories": [
null
],
"article": { ... }
}
}
}
This is fixed in #19
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
japx is not able to parse the relationships in include. In the example file above the user relationship with comments is not decoded. It seems the included parameter support is not sufficient.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.