Firebase rest api response cant parse json responses
See original GitHub issueSo I have try to implement this using firebase database, for building the json, I get same response from a normal rest api client and other from firebase REST API database, but the json response is pretty much the same.
REST: application/json
{"type":"LinearLayout","layout_width":"match_parent","layout_height":"200dp","orientation":"vertical","padding":"16dp","background":"#cccccc"}
Firebase: application/json; charset=utf-8
{"background":"#cccccc","layout_height":"200dp","layout_width":"match_parent","orientation":"vertical","padding":"16dp","type":"LinearLayout"}
So this layout cant be parse
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
Firebase REST API POST request fails with error: "Invalid data
I tried with jQuery and vanilla JS XHR. However, both give the same error. 403 Bad Request and this response: Invalid data; couldn't...
Read more >Firebase Database REST API
A successful DELETE request is indicated by a 200 OK HTTP status code with a response containing JSON null . ... Unable to...
Read more >HTTP status and error codes for JSON | Cloud Storage
The following document provides reference information about the status codes and error messages that are used in the Cloud Storage JSON API.
Read more >Download Firebase config file or object - Google Help
Get config file for your Android app · Go to your the Settings icon · In the Your apps card, select the package...
Read more >App rejection due to JSON parsing | Apple Developer Forums
We are speculating the parameter is in correct format because the users from same location(our client) able to do API call successfully and...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found a solution, to avoid this issue of sorting I made a custom sorter for the JSON, I have made this script that will look for the type node in the JSON and childrens
ProteusUtils.kt
You might need to share some stack traces for why it “can’t be parse”.
My best guess?
"type":LinearLayout"
should be the first property of the JSON. It seems the firebase serialises JSON properties alphabetically. But the ProteusTypeAdapterFactory#VALUE_TYPE_ADAPTER expectstype
to be the first property to be even considered as a layout object (this is a performance optimisation strategy).Maybe check out How Data is Ordered in Firebase.