Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Retrive ListObjects #42

Open
Orinameh opened this issue Aug 26, 2018 · 2 comments
Open

Retrive ListObjects #42

Orinameh opened this issue Aug 26, 2018 · 2 comments

Comments

@Orinameh
Copy link

I have been trying to retrieve ListObjects but all to no avail. The issue here is the mClass. How do I go about it? Thanks. Nice work anyways

@kcochibili
Copy link
Owner

can you show me the code where you're trying to retrieve the list?
also what is the specific problem you're encountering when you try to retrieve the list?

@helen-hjy
Copy link

helen-hjy commented May 27, 2020

Hi, I have problem invoking getListObject(). It says: Caused by: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING at line 1 column 1 path $..

The code with problem is:
Object value = gson.fromJson(jObjString,mClass);
I have a customized class called Property. gson.fromJson() does have a kind that with 1st parameter being string. I 'm so confused with this error.

Also, could you check my code with my own class? i'm not sure if it's right since ArrayList<Object> caused error as returned value for my customized class.

public ArrayList<Property> getListObject(String key, Class<?> mClass){
    Gson gson = new Gson();

    ArrayList<String> objStrings = getListString(key);
    ArrayList<Property> objects = new ArrayList<>();

    for(String jObjString : objStrings){
            Object value  = gson.fromJson({jObjString},mClass);
            objects.add((Property) value);
        }
    return objects;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants