How to parse “[ ”a“, [ ”adidas“, ”acb“, ”amazon" ] ] to object java?

50
September 18, 2019, at 10:10 AM

I can't converter this response api "[ "a", [ "adidas", "acb", "amazon" ] ] to object java or kotlin

Answer 1

The format of your JSON data is not very suitable to convert to a java object directly´╝îtry to make your JSON data like this:

{"a": ["adidas", "acb", "amazon"] }

or

{"keyA" : "a", "keyB" : ["adidas", "acb", "amazon"] }

But it's still depends on what is your actual demand

You can test your JSON data here:

JSON to JAVA Converter live

Answer 2

May be this example can help you.

public class Test {

    public static void main(String... args) throws Exception {
        String json = "[ "a", [ "adidas", "acb", "amazon" ] ];  
        // Now do the magic.
        Data data = new json().fromJson(json, Data.class);
        // Show it.
        System.out.println(data);
    }
}
class Data {
    private String data;
    private List<String> groups;
    public String getData() { return data; }
    public void setData(String data) { this.data= data; }
    public List<String> getGroups() { return groups; }
    public void setGroups(List<String> groups) { this.groups = groups; }
    }
READ ALSO
I opened android project but project can get SDK-tools

I opened android project but project can get SDK-tools

In MainAcitivity i am using ToolssystemBarLolipop() it is function from Tools

26
How to reduce video size with java/kotlin on Android?

How to reduce video size with java/kotlin on Android?

I want reduce the video size at Android Studio and for upload to PlayStore needs to be compatible for 64 bits arquitecture, I tried before with ffmpeg and it compress mp4 succefully but take longer time and this solution with 3gp not include the audioTheres...

55
Google sheets to salesforce

Google sheets to salesforce

Im trying to connect data in google sheet to salesforce

17