JSON to Java class

后端 未结 4 642
说谎
说谎 2021-02-13 15:22

Is there an easy way to map data from JSON to fields of my class by means of android APIs?

JSON:

{ email: \'email\', password: \'pass\' }
4条回答
  •  时光取名叫无心
    2021-02-13 15:52

    Use the org.json-Package.

    JSONObject x = new JSONObject(jsonString);
    Credentials c = new Credentials();
    c.email = x.getString("email");
    c.password = x.getString("password");
    

    Its also part of the android runtime, so you dont need any external package.

提交回复
热议问题