how to Parse facebook JSON response

前端 未结 2 743
-上瘾入骨i
-上瘾入骨i 2021-01-23 21:27

I think the return value from facebook is ambiguous.:

    loginButton.registerCallback(callbackManager, new FacebookCallback() {
        @Over         


        
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-23 21:57

    What about using google gson? https://github.com/google/gson

    I use it for every Android project where I need to serialize/deserialize json. Give it a try, here are some basic examples for you which should satisfy your needs:

    Deserialization:

    int one = gson.fromJson("1", int.class);
    Integer one = gson.fromJson("1", Integer.class);
    Long one = gson.fromJson("1", Long.class);
    Boolean false = gson.fromJson("false", Boolean.class);
    String str = gson.fromJson("\"abc\"", String.class);
    String anotherStr = gson.fromJson("[\"abc\"]", String.class);
    

    If not, check the documentation here: https://sites.google.com/site/gson/gson-user-guide

提交回复
热议问题