We are currently trying to communicate with Android Studio using retrofit2 library.
The server is using the restful API and responds with a json type.
Expected BEGIN_ARRAY but BEGIN_OBJECT at line 1 column 2 path $ There is an error like this, but the problem occurs only when I try to import more than two in the current array. (One is well received)
I don't think I'm getting the right data format.I don't know what to do. I can't understand even if I search it, so please help me.
Below is a single data type part.
@JsonIgnoreProperties(ignoreUnknown=true)
public class ResultsVersion {
private String file_name;
private String version;
public String getFile_name() {
return file_name;
}
public void setFile_name(String file_name) {
this.file_name = file_name;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
}
Below are two or more array data types.
public class ResultsVersionList {
private ResultsVersion[] resultsVersions;
public ResultsVersion[] getResultsVersions() {
return resultsVersions;
}
}
Below is the part that manages the restful API address.
@Headers("Content-Type: application/json")
@GET(Constant.URL_CURRENT_FIRMWARE_VERSION)
Call<ResultsVersionList> getCurrentFirmwareVersionList();
Below is the json data sent by the server.
[
{
"file_name": "app5910.apk",
"version": "5.9.10"
},
{
"file_name": "app533.apk",
"version": "5.3.3"
},
{
"file_name": "app532.apk",
"version": "5.3.2"
},
{
"file_name": "app5101.apk",
"version": "5.10.1"
}
]
Call<List<ResultsVersion>> getCurrentFirmwareVersionList();
Can't we get it this way?
Take it as an object and put it on the list.
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
611 GDB gets version error when attempting to debug with the Presense SDK (IDE)
578 Understanding How to Configure Google API Key
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
574 Who developed the "avformat-59.dll" that comes with FFmpeg?
© 2024 OneMinuteCode. All rights reserved.