【问题标题】:How I can parse a response of this request?我如何解析这个请求的响应?
【发布时间】:2019-09-04 03:41:35
【问题描述】:

块引用

public class MainActivity extends AppCompatActivity {

 

    private TextView mTextViewResult;

 

    @Override

    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        setContentView(R.layout.activity_main);

 

        mTextViewResult = findViewById(R.id.text_view_result);

 

        OkHttpClient client = new OkHttpClient();

 

        String url = "https://reqres.in/api/users?page=2";

 

        Request request = new Request.Builder()

                .url(url)

                .build();

 

        client.newCall(request).enqueue(new Callback() {

            @Override

            public void onFailure(Call call, IOException e) {

                e.printStackTrace();

            }

 

            @Override

            public void onResponse(Call call, Response response) throws IOException {

                if (response.isSuccessful()) {

                    final String myResponse = response.body().string();

 

                    MainActivity.this.runOnUiThread(new Runnable() {

                        @Override

                        public void run() {

                            mTextViewResult.setText(myResponse);

                        }

                    });

                }

            }

        });

    }

}

块引用

[{"attributes": {"message": "这里有一些入门资源:\n\n - Configuring Home Assistant\n - Available components\n - Troubleshooting your configuration\n - Getting help\ n\n要以后看不到此卡片弹出窗口,请在\nconfiguration.yaml 中编辑您的配置并禁用introduction 组件。", "title": "Welcome Home!"}, "context": {"id" :“840e4ec2072144cfa7d53550796dc35d”,“parent_id”:null,“user_id”:null},“entity_id”:“persistent_notification.notification”,“last_changed”:“2019-04-11T22:44:04.942593+00:00”,“last_updated” “:“2019-04-11T22:44:04.942593+00:00”,“状态”:“通知”},{“属性”:{“方位角”:282.29,“海拔”:37.79,“友好名称”:“太阳”、“next_dawn”:“2019-04-15T05:35:52+00:00”、“next_dusk”:“2019-04-14T18:24:46+00:00”、“next_midnight”:“2019- 04-15T00:00:05+00:00”,“next_noon”:“2019-04-15T12:00:13+00:00”,“next_rising”:“2019-04-15T05:56:50+00: 00”,“next_setting”:“2019-04-14T18:03:50+00:00”},“上下文”:{“id”:“a8908c263c854345a518358553319876”,“parent_id”:null,“user_id”:null}, “实体 ID”: “sun.sun”、“last_changed”:“2019-04-14T05:57:06.013733+00:00”、“last_updated”:“2019-04-14T15:26:30.009359+00:00”、“状态”: "above_horizo​​n"}, {"attributes": {"attribution": "met.no 的天气预报,由挪威气象研究所提供。", "entity_picture": "https://api.met.no/weatherapi/weathericon/1.1/?symbol=10;content_type=image/png", "friendly_name": "yr Symbol" },“上下文”:{“id”:“e2d38361a1704e2a97a78dca780e2e20”,“parent_id”:null,“user_id”:null},“entity_id”:“sensor.yr_symbol”,“last_changed”:“2019-04-14T14:31 :00.098478+00:00", "last_updated": "2019-04-14T14:31:00.098478+00:00", "state": "10"}, {"attributes": {"friendly_name": "potenza massima" stufa”,“last_triggered”:null},“context”:{“id”:“708bfbddda494f07a11506b5e69e3add”,“parent_id”:null,“user_id”:null},“entity_id”:“script.1547400071844”,“last_changed”: “2019-04-11T22:44:27.871225+00:00”,“last_updated”:“2019-04-11T22:44:27.871225+00:00”,“状态”:“关闭”},{“属性”: {“friendly_name”:“potenza minima stufa”,“last_triggered”:null},“context”:{“id”:“ 9721b6341250436e8050556e44015ebd,“parent_id”:null,“user_id”:null},“entity_id”:“script.1547305398108”,“last_changed”:“2019-04-11T22:44:27.872132+00:00”,“last_updated”: "2019-04-11T22:44:27.872132+00:00", "state": "off"}, {"attributes": {"device_class": "connectivity", "friendly_name": "Remote UI"}, "上下文”:{“id”:“4429627581ef481785396af892bb92cc”,“parent_id”:null,“user_id”:null},“entity_id”:“binary_sensor.remote_ui”,“last_changed”:“2019-04-11T22:44:27.901163+ 00:00”,“last_updated”:“2019-04-11T22:44:27.901163+00:00”,“状态”:“不可用”},{“属性”:{“access_token”:“6304d62742f4b9792101bdb83ee7a7953c1263bc7276e452ebent56” “: ”/api/camera_proxy/camera.front_window?token=6304d62742f4b9792101bdb83ee7a7953c1263bc7276e42e6b4f5c6b8a579253“, ”FRIENDLY_NAME“: ”前窗“, ”supported_features“:0}, ”上下文“:{” ID“: ”53ddda3891f24b2b88ecedf43d27186a“, ”PARENT_ID“:空,“user_id”:null},“entity_id”:“camera.front_window”,“last_changed”: “2019-04-11T22:44:27.911773+00:00”,“last_updated”:“2019-04-14T15:22:32.548799+00:00”,“状态”:“空闲”},{“属性”: {"auto": true, "entity_id": ["script.1547400071844", "script.1547305398108"], "friendly_name": "所有脚本", "hidden": true, "order": 0}, "context" :{“id”:“d0230ccfddf4407fab7e784b3539fa3b”,“parent_id”:null,“user_id”:null},“entity_id”:“group.all_scripts”,“last_changed”:“2019-04-11T22:44:27.914874+00: 00”,“last_updated”:“2019-04-11T22:44:27.914874+00:00”,“状态”:“off”},{“属性”:{“commands_encoding”:“Base64”,“device_code”: 1000,“friendly_name”:“Tv Sala da Pranzo”,“制造商”:“Samsung”,“supported_controller”:“Broadlink”,“supported_features”:3512,“supported_models”:[“UE40F6500”]},“context”: {“id”:“a6dd1bd45e6e48338fd5d22246a27b48”,“parent_id”:null,“user_id”:null},“entity_id”:“media_player.tvsalotto”,“last_changed”:“2019-04-11T22:44:27.995463+00:00 ", "last_updated": "2019-04-11T22:44:27.995463+00:00", "state": "off"}, {"attrib utes”:{“friendly_name”:“Riscaldamento al massimo”,“icon”:“mdi:radiator”},“context”:{“id”:“6c12c666d4df4b26a08ec20ea6769489”,“parent_id”:null,“user_id”:null} ,“entity_id”:“input_boolean.riscaldamento_massimo”,“last_changed”:“2019-04-11T22:44:27.996785+00:00”,“last_updated”:“2019-04-11T22:44:27.996785+00:00” ,“状态”:“关闭”},{“属性”:{“友好名称”:“Porta Studio”,“图标”:“mdi:门”},“上下文”:{“id”:“4ce7d589575b419b84f6b8bf7a2cd1d8”,“ parent_id”:null,“user_id”:null},“entity_id”:“input_boolean.porta_studio”,“last_changed”:“2019-04-11T22:44:27.998025+00:00”,“last_updated”:“2019-04 -11T22:44:27.998025+00:00", "state": "off"}, {"attributes": {"friendly_name": "Porta Ingresso", "icon": "mdi:door"}, "context" :{“id”:“946c2c4bf6774a75b5b387738670c623”,“parent_id”:null,“user_id”:null},“entity_id”:“input_boolean.porta_ingresso”,“last_changed”:“2019-04-11T22:44:27.999169+00: 00", "last_updated": "2019-04-11T22:44:27.999169+00:00", "state": "off"}, {"at贡品”:{“friendly_name”:“Movimento Salotto9”,“icon”:“mdi:security-account”},“context”:{“id”:“4923466b5c9a4d0e8e9e9143f42a926a”,“parent_id”:null,“user_id”:null },“entity_id”:“input_boolean.movi​​mento_salotto9”,“last_changed”:“2019-04-11T22:44:28.000306+00:00”,“last_updated”:“2019-04-11T22:44:28.000306+00:00” ", "state": "off"}, {"attributes": {"friendly_name": "Movimento Salotto2", "icon": "mdi:security-account"}, "context": {"id": "8314408ca4154fbcb717cd931fd81a44 ", "parent_id": null, "user_id": null}, "entity_id": "input_boolean.movi​​mento_salotto2", "last_changed": "2019-04-11T22:44:28.001453+00:00", "last_updated": " 2019-04-11T22:44:28.001453+00:00", "state": "off"}, {"attributes": {"friendly_name": "Allarme Totale", "icon": "mdi:alarm-light" },“上下文”:{“id”:“f6e8df0876134847b58c26a1e04c768c”,“parent_id”:null,“user_id”:null},“entity_id”:“input_boolean.allarme_inserito”,“last_changed”:“2019-04-11T22:44 :28.002440+00:00”,“last_updated”:“2019-04-11T22:44:28。 002440+00:00", "state": "off"}, {"attributes": {"friendly_name": "Movimento Salotto8", "icon": "mdi:security-account"}, "context": {" id”:“2d7c89058b85494980d47181ff0e5fa2”,“parent_id”:null,“user_id”:null},“entity_id”:“input_boolean.movi​​mento_salotto8”,“last_changed”:“2019-04-11T22:44:28.003254+00:00”, "last_updated": "2019-04-11T22:44:28.003254+00:00", "state": "off"}, {"attributes": {"friendly_name": "Movimento Salotto3", "icon": "mdi :security-account"}, "context": {"id": "d64679da21464decb5c850b5e8c8337f", "parent_id": null, "user_id": null}, "entity_id": "input_boolean.movi​​mento_salotto3", "last_changed": "2019- 04-11T22:44:28.004103+00:00", "last_updated": "2019-04-11T22:44:28.004103+00:00", "state": "off"}, {"attributes": {"friendly_name ": "Allarme Notturno", "icon": "mdi:alarm-light"}, "context": {"id": "5be17c7837e948ecbf6249c71c101756", "parent_id": null, "user_id": null}, "entity_id": “input_boolean.allarme_notturno_inserito”,“last_changed”:“2019-04-11T22:44:28.00491 6+00:00", "last_updated": "2019-04-11T22:44:28.004916+00:00", "state": "off"}, {"attributes": {"friendly_name": "Movimento Salotto7" , "icon": "mdi:security-account"}, "context": {"id": "8f5e0deaa7664312b81268b7c37c6ca4", "parent_id": null, "user_id": null}, "entity_id": "input_boolean.movi​​mento_salotto7", "last_changed": "2019-04-11T22:44:28.005613+00:00", "last_updated": "2019-04-11T22:44:28.005613+00:00", "state": "off"}, { “属性”:{“friendly_name”:“Movimento Salotto4”,“图标”:“mdi:security-account”},“上下文”:{“id”:“2e3fb03b63364ef7854fae397f3fc0cb”,“parent_id”:null,“user_id”: null},“entity_id”:“input_boolean.movi​​mento_salotto4”,“last_changed”:“2019-04-11T22:44:28.006301+00:00”,“last_updated”:“2019-04-11T22:44:28.006301+00: 00", "state": "off"}, {"attributes": {"friendly_name": "Movimento Salotto6", "icon": "mdi:security-account"}, "context": {"id": " a53871f915a94afa82d963fc3919f9fe”,“parent_id”:null,“user_id”:null},“entity_id”:“input_boolean.movi​​mento_salott o6”、“last_changed”:“2019-04-11T22:44:28.006999+00:00”、“last_updated”:“2019-04-11T22:44:28.006999+00:00”、“状态”:“关闭” }, {"属性": {"friendly_name": "Movimento Salotto5", "icon": "mdi:security-account"}, "context": {"id": "c8531835897942da9006338c41a2dcb8", "parent_id": null, " user_id”:null},“entity_id”:“input_boolean.movi​​mento_salotto5”,“last_changed”:“2019-04-11T22:44:28.007795+00:00”,“last_updated”:“2019-04-11T22:44:28.007795 +00:00", "state": "off"}, {"attributes": {"friendly_name": "Movimento Salotto1", "icon": "mdi:security-account"}, "context": {"id “:“8ff65a959e284df7bc2ab212feddef43”,“parent_id”:null,“user_id”:null},“entity_id”:“input_boolean.movi​​mento_salotto1”,“last_changed”:“2019-04-11T22:44:28.008593+00:00”,“ last_updated": "2019-04-11T22:44:28.008593+00:00", "state": "off"}, {"attributes": {"friendly_name": "Movimento Salotto", "icon": "mdi:安全帐户”},“上下文”:{“id”:“2743ddd129ac46fa8e8301c5a8ffd2ad”,“parent_id”:null,“user_id”:null} ,“entity_id”:“input_boolean.movi​​mento_salotto”,“last_changed”:“2019-04-11T22:44:28.009284+00:00”,“last_updated”:“2019-04-11T22:44:28.009284+00:00” ,“状态”:“关闭”},{“属性”:{“友好名称”:“Porta Terrazzo”,“图标”:“mdi:门”},“上下文”:{“id”:“942ae296eb984f4e95aad36f0d58060b”,“ parent_id”:null,“user_id”:null},“entity_id”:“input_boolean.porta_terrazzo”,“last_changed”:“2019-04-11T22:44:28.009986+00:00”,“last_updated”:“2019-04 -11T22:44:28.009986+00:00", "state": "off"}, {"attributes": {"friendly_name": "Porta Balcone", "icon": "mdi:door"}, "context" :{“id”:“8f3ab0b57dc84e74870f8bd25be344df”,“parent_id”:null,“user_id”:null},“entity_id”:“input_boolean.porta_balcone”,“last_changed”:“2019-04-11T22:44:28.010830+00: 00", "last_updated": "2019-04-11T22:44:28.010830+00:00", "state": "off"}, {"attributes": {"friendly_name": "Porta Bimbi", "icon" :“mdi:门”},“上下文”:{“id”:“0349ed4a9a5640eab08700c95acb7300”,“parent_id”:null,“user_id”:null},“entity_id”: “input_boolean.porta_bimbi”、“last_changed”:“2019-04-11T22:44:28.011848+00:00”、“last_updated”:“2019-04-11T22:44:28.011848+00:00”、“状态”: “off”},{“attributes”:{“friendly_name”:“Porta Bagno”,“icon”:“mdi:door”},“context”:{“id”:“ec8cdbc049ba45b39001d70d36e90e80”,“parent_id”:null, “user_id”:null},“entity_id”:“input_boolean.porta_bagno”,“last_changed”:“2019-04-11T22:44:28.013939+00:00”,“last_updated”:“2019-04-11T22:44: 28.013939+00:00", "state": "off"}, {"attributes": {"friendly_name": "Riscaldamento Max/Min", "icon": "mdi:hot-tub"}, "context": {“id”:“54770f9b1d6144ad9895dc7a5110ae2c”,“parent_id”:null,“user_id”:null},“entity_id”:“input_boolean.potenza_stufa”,“last_changed”:“2019-04-11T22:44:28.015161+00:00 ", "last_updated": "2019-04-11T22:44:28.015161+00:00", "state": "off"}, {"attributes": {"friendly_name": "Porta Letto", "icon": “mdi:door”},“context”:{“id”:“44f37bd1e830460c93a9e2b8e4dcc562”,“parent_id”:null,“user_id”:null},“entity_id”:“input_boolean.p orta_letto”、“last_changed”:“2019-04-11T22:44:28.016018+00:00”、“last_updated”:“2019-04-11T22:44:28.016018+00:00”、“状态”:“关闭” }, {"属性": {"friendly_name": "Buonanotte", "icon": "mdi:weather-night"}, "context": {"id": "71d91d353ae24fb783edf8447d9eb816", "parent_id": null, "user_id ": null}, "entity_id": "input_boolean.buonanotte", "last_changed": "2019-04-11T22:44:28.016736+00:00", "last_updated": "2019-04-11T22:44:28.016736+ 00:00", "state": "off"}, {"attributes": {"commands_encoding": "Base64", "current_temperature": null, "device_code": 1060, "fan_list": ["low", " mid”、“high”、“auto”]、“fan_mode”:“mid”、“friendly_name”:“Cmeretta AC”、“last_on_operation”:“cool”、“manufacturer”:“LG”、“max_temp”:30 ,“min_temp”:18,“operation_list”:[“off”,“heat”,“cool”,“auto”,“dry”,“fan”],“operation_mode”:“off”,“supported_controller”:“ Broadlink”,“supported_features”:4289,“supported_models”:[“R09AWN”,“R24AWN”,“E09EK”],“target_temp_step”:1,“温度”:20},“上下文”:{ “id”:“415929712c804d41a59535267467a55e”,“parent_id”:null,“user_id”:null},“entity_id”:“climate.cmeretta_ac”,“last_changed”:“2019-04-11T22:44:28.018072+00:00” , "last_updated": "2019-04-11T22:44:28.018072+00:00", "state": "off"}, {"attributes": {"commands_encoding": "Base64", "current_temperature": null, “device_code”:1101,“fan_list”:[“auto”,“night”,“low”,“lowMedium”,“medium”,“mediumHigh”,“high”,“powerful”],“fan_mode”:“low ", "friendly_name": "Salotto AC", "last_on_operation": "heat", "manufacturer": "Daikin", "max_temp": 30.0, "min_temp": 18.0, "operation_list": ["off", "auto ”,“干”,“酷”,“风扇”,“热”],“操作模式”:“热”,“supported_controller”:“Broadlink”,“supported_features”:4289,“supported_models”:[“FTXS20LVMA”, “FTXS25LVMA”、“FTXS35LVMA”、“FTXS46LVMA”、“FTXS50LVMA”、“FTXS60LVMA”、“FTXS71LVMA”、“FTXS85LVMA”、“FTXS95LVMA”]、“target_temp_step”:1.0、“温度”:28}、“上下文”: {“id”:“6983bd558bfa4d3aacf315093e751b2f”,“parent_id”:空,“user_id” :“ecc652675a024d2fa17de965f2b758e5”},“entity_id”:“climate.salotto_ac_2”,“last_changed”:“2019-04-13T21:07:14.011233+00:00”,“last_updated”:“2019-04-13T284:07:51.76 +00:00", "state": "heat"}, {"attributes": {"friendly_name": "Riscaldamento al massimo off", "id": "1546977979696", "last_triggered": "2019-03-15T00 :31:33.759146+00:00"}, "context": {"id": "4b58de64188e4db69a567fbb9b0d9ccb", "parent_id": null, "user_id": null}, "entity_id": "automation.riscaldamento_al_massimo_off", "last_changed" :“2019-04-11T22:44:38.891361+00:00”,“last_updated”:“2019-04-11T22:44:38.891361+00:00”,“状态”:“on”},{“属性” : {"friendly_name": "Stufa Potenza al minimo", "id": "1547401156274", "last_triggered": "2019-03-15T00:31:27.848705+00:00"}, "context": {"id" :“69f610d7f8e34d51872a150d2976f92a”,“parent_id”:null,“user_id”:null},“entity_id”:“automation.stufa_potenza_al_minimo”,“last_changed”:“2019-04-11T22:44:38.897480+00:00”,“last_updated” ": "2019-04-11T22:44:38.897480+00:00", "状态": “on”},{“attributes”:{“friendly_name”:“启动通知”,“id”:“7482bc2efbf740f78fb4170aba403f55”,“last_triggered”:“2019-04-11T22:44:38.978668+00:00”},“上下文”:{“id”:“6fb93349693d43918b0aad3f28cc1cd4”,“parent_id”:null,“user_id”:null},“entity_id”:“automation.startup_notification”,“last_changed”:“2019-04-11T22:44:38.906247+ 00:00", "last_updated": "2019-04-11T22:44:38.979756+00:00", "state": "on"}, {"attributes": {"friendly_name": "Stufa Potenza al Massimo" , "id": "1547401206250", "last_triggered": "2019-03-15T00:28:35.425947+00:00"}, "context": {"id": "461029cd27bc4d7b8ea69ed6e07f5a9e", "parent_id": null, " user_id”:null},“entity_id”:“automation.stufa_potenza_al_massimo”,“last_changed”:“2019-04-11T22:44:38.912871+00:00”,“last_updated”:“2019-04-11T22:44:38.912871 +00:00", "state": "on"}, {"attributes": {"friendly_name": "同步 Google Home", "id": "1551485840564", "last_triggered": "2019-04-11T22: 44:39.446583+00:00"},“上下文”:{“id”:“b19fd4e189e6494fa01d9996d49 c6687”、“parent_id”:null、“user_id”:null}、“entity_id”:“automation.sync_google_home”、“last_changed”:“2019-04-11T22:44:38.918581+00:00”、“last_updated”: "2019-04-11T22:44:39.447259+00:00", "state": "on"}, {"attributes": {"friendly_name": "Riscaldamento al massimo on", "id": "1546977516568", “last_triggered”:“2019-03-15T00:28:41.383403+00:00”},“context”:{“id”:“7ca9a3abb253460f874395f83ae46af9”,“parent_id”:null,“user_id”:null},“entity_id” :“automation.riscaldamento_al_massimo_on”,“last_changed”:“2019-04-11T22:44:38.924212+00:00”,“last_updated”:“2019-04-11T22:44:38.924212+00:00”,“状态” : "on"}, {"attributes": {"auto": true, "entity_id": ["automation.riscaldamento_al_massimo_off", "automation.riscaldamento_al_massimo_on", "automation.startup_notification", "automation.stufa_potenza_al_massimo", "automation. stufa_potenza_al_minimo", "automation.sync_google_home"], "friendly_name": "所有自动化", "hidden": true, "order": 1}, "context": {"id": "702f50f2068741a589f2ef90d6 95c5d1”、“parent_id”:null、“user_id”:null}、“entity_id”:“group.all_automations”、“last_changed”:“2019-04-11T22:44:38.953809+00:00”、“last_updated”: “2019-04-11T22:44:38.953809+00:00”、“状态”:“开启”}、{“属性”:{“效果列表”:[“blue_fade”、“blue_strobe”、“colorjump”、“colorloop” ”,“colorstrobe”,“cyan_fade”,“cyan_strobe”,“gb_cross_fade”,“green_fade”,“green_strobe”,“purple_fade”,“purple_strobe”,“rb_cross_fade”,“red_fade”,“red_strobe”,“rg_cross_fade”, “white_fade”,“white_strobe”,“yellow_fade”,“yellow_strobe”,“random”],“friendly_name”:“led letto”,“supported_features”:149},“context”:{“id”:“26e38cbd1a9e4539a0c15184cb96e3f1”, “parent_id”:null,“user_id”:null},“entity_id”:“light.led_letto”,“last_changed”:“2019-04-11T22:44:28.890393+00:00”,“last_updated”:“2019- 04-11T22:44:28.890393+00:00", "state": "off"}, {"attributes": {"friendly_name": "Chromecast", "supported_features": 21437}, "context": {"id ": "622ebdf42c9c4385aba11b0ead8a2ba9", "parent_id": null, "我们er_id”:null},“entity_id”:“media_player.chromecast”,“last_changed”:“2019-04-14T14:03:36.408724+00:00”,“last_updated”:“2019-04-14T14:03:36.408724 +00:00", "state": "off"}, {"attributes": {"friendly_name": "Google home mini", "supported_features": 21437}, "context": {"id": "4d310fe44cba4a1aa4818f5f8a48f17e" ,“parent_id”:null,“user_id”:null},“entity_id”:“media_player.google_home_mini”,“last_changed”:“2019-04-14T02:30:04.840943+00:00”,“last_updated”:“2019 -04-14T02:30:04.840943+00:00", "state": "off"}, {"attributes": {"auto": true, "entity_id": ["light.00828041b4e62d5c5b98", "light.32787642b4e62d621c0d ", "light.led_letto", "light.20578840cc50e34e906f"], "friendly_name": "所有灯", "hidden": true, "order": 2}, "context": {"id": "d1e4a1746a6149f2af8c215953635f29", “parent_id”:null,“user_id”:null},“entity_id”:“group.all_lights”,“last_changed”:“2019-04-11T22:44:28.911301+00:00”,“last_updated”:“2019- 04-11T22:44:38.824706+00:00”,“状态”:“关闭”},{“属性”:{“设备_ id”:“1000549784”,“friendly_name”:“音频 1”,“rssi”:-35},“context”:{“id”:“7f2ef0d2229146f7802473b9990dd7fc”,“parent_id”:null,“user_id”:null}, “entity_id”:“switch.sonoff_1000549784_1”、“last_changed”:“2019-04-14T09:23:27.244186+00:00”、“last_updated”:“2019-04-14T15:22:37.015952+00:00”、 “状态”:“on”},{“属性”:{“device_id”:“1000549784”,“friendly_name”:“音频 4”,“rssi”:-35},“上下文”:{“id”:“ ddf58a8694b64ad4b3db65b12a073b6a”,“parent_id”:null,“user_id”:null},“entity_id”:“switch.sonoff_1000549784_4”,“last_changed”:“2019-04-14T09:23:33.499192+00:00”,“last_updated”: "2019-04-14T15:22:37.018065+00:00", "state": "on"}, {"attributes": {"device_id": "1000549784", "friendly_name": "Audio 2", "rssi “:-35},“上下文”:{“id”:“422f327e15554cc594c741b8139eec1f”,“parent_id”:null,“user_id”:null},“entity_id”:“switch.sonoff_1000549784_2”,“last_changed”:“2019-04 -14T09:23:41.644737+00:00", "last_updated": "2019-04-14T15:22:37.014715+00:00", "state": "on"}, {"attri butes”:{“device_id”:“1000549784”,“friendly_name”:“音频 3”,“rssi”:-35},“context”:{“id”:“6c4583d9cea943009d71a2089989eb07”,“parent_id”:null,“user_id” ": null}, "entity_id": "switch.sonoff_1000549784_3", "last_changed": "2019-04-14T09:23:47.606677+00:00", "last_updated": "2019-04-14T15:22:37.017017+ 00:00", "state": "on"}, {"attributes": {"message": "以下组件和平台无法设置:\n\n - sonoff.sensor\n\n请检查您的config.", "title": "无效配置"}, "context": {"id": "d20f246e9417435ca51c556863d456eb", "parent_id": null, "user_id": null}, "entity_id": "persistent_notification.invalid_config", “last_changed”:“2019-04-11T22:44:35.112518+00:00”,“last_updated”:“2019-04-11T22:44:35.112518+00:00”,“状态”:“通知”},{ “属性”:{“auto”:true,“Entity_ID”:[“switch.soff_1000549784_1”,“switch.sonoff_1000549784_2”,“switch.sonoff_1000549784_3”,“switch.sonoff_1000549784_4”,“switch.70014205C44f33859ce7_1”,“switch.70014205C44F33859CE7_2 " , "switch.70014205c44f33859ce7_3", "switch.70014205c44f33859ce7_7", "switch.78487660840d8e89c5c5", "switch.404847023c71bf236b37"], "friendly_name": "所有开关", "hidden"text: true, "order" “:{“id”:“c8fdc50e2ef146d0beb6c3cdba6e12b6”,“parent_id”:null,“user_id”:null},“entity_id”:“group.all_switches”,“last_changed”:“2019-04-14T09:23:27.251808+00 :00", "last_updated": "2019-04-14T09:23:27.251808+00:00", "state": "on"}, {"attributes": {"access_token": "c55c723edf0b85dd54962fbffbdc018864d5af84b2db44729bbbc7e155b8", : “/api/camera_proxy/camera.onvif_camera?token=c55c723edf0b85dd54962fbffbdc018864d5af84b2db4472bbbc7e155b8eee91”, “FRIENDLY_NAME”: “ONVIF摄像机”, “supported_features”:0}, “情境”:{ “ID”: “a713a6b59f9b4fb2adda6a1f32941b54”, “PARENT_ID”:空, "user_id": null}, "entity_id": "camera.onvif_camera", "last_changed": "2019-04-11T22:44:37.879996+00:00", "last_updated": "2019-04-14T15:22 :32.547773+00:00", "状态": "空闲"}, {"属性": {"朋友ly_name”:“comodino”,“supported_features”:17},“context”:{“id”:“8cb8b68a8f19492990896e7cd7bb1753”,“parent_id”:null,“user_id”:null},“entity_id”:“light.32787642b4e62d621c0d”, “last_changed”:“2019-04-11T22:44:38.801549+00:00”,“last_updated”:“2019-04-11T22:44:38.801549+00:00”,“状态”:“不可用”},{ “属性”:{“friendly_name”:“RGB Led”,“supported_features”:19},“上下文”:{“id”:“a02d62d5f683469390dbf5162c4b0628”,“parent_id”:null,“user_id”:null},“entity_id” :“light.00828041b4e62d5c5b98”、“last_changed”:“2019-04-11T22:44:38.803512+00:00”、“last_updated”:“2019-04-11T22:44:38.803512+00:00”、“状态” :“不可用”},{“属性”:{“friendly_name”:“scrivania filippo”,“supported_features”:19},“上下文”:{“id”:“d0ffe21f5d9743f39504af1d5bcb4ae6”,“parent_id”:null,“user_id” :null},“entity_id”:“light.20578840cc50e34e906f”,“last_changed”:“2019-04-11T22:44:38.805453+00:00”,“last_updated”:“2019-04-11T22:44:38.805453+00” :00", "状态": "不可用"}, {"属性tes”:{“friendly_name”:“tv Filippo”},“context”:{“id”:“a3eac8a4b6344cd89ed0524bc587160c”,“parent_id”:null,“user_id”:null},“entity_id”:“switch.404847023c71bf236b37”, "last_changed": "2019-04-14T09:23:41.643461+00:00", "last_updated": "2019-04-14T09:23:41.643461+00:00", "state": "on"}, { “属性”:{“friendly_name”:“Switch 3”},“上下文”:{“id”:“78b4caa4b7fe42a981a564addaccfa46”,“parent_id”:null,“user_id”:null},“entity_id”:“switch.70014205c44f33859ce7_3” ,“last_changed”:“2019-04-11T22:44:38.809387+00:00”,“last_updated”:“2019-04-11T22:44:38.809387+00:00”,“状态”:“不可用”}, {“属性”:{“友好名称”:“开关 2”},“上下文”:{“id”:“eb7c8a0f29e3461bb542ccee0be97ff3”,“parent_id”:null,“user_id”:null},“entity_id”:“switch.70014205c44f33859ce7_2 ", "last_changed": "2019-04-11T22:44:38.811297+00:00", "last_updated": "2019-04-11T22:44:38.811297+00:00", "state": "不可用"} ,{“属性”:{“友好名称”:“scaldaletto”},“上下文”:{“id”:“e56ccbe189e94c deb6da4ccd5fddef5a”,“parent_id”:null,“user_id”:null},“entity_id”:“switch.78487660840d8e89c5c5”,“last_changed”:“2019-04-14T09:35:04.885554+00:00”,“last_updated”: "2019-04-14T09:35:04.885554+00:00", "state": "off"}, {"attributes": {"friendly_name": "Switch 1"}, "context": {"id": “b4560597da9945a0839312f1f6eb45ba”、“parent_id”:null、“user_id”:null}、“entity_id”:“switch.70014205c44f33859ce7_1”、“last_changed”:“2019-04-11T22:44:38.815400+00:00”、“last_updated” : "2019-04-11T22:44:38.815400+00:00", "state": "unavailable"}, {"attributes": {"friendly_name": "Switch 7"}, "context": {"id" :“b76e97a7fb2d44c2b237a6e70c2285ef”,“parent_id”:null,“user_id”:null},“entity_id”:“switch.70014205c44f33859ce7_7”,“last_changed”:“2019-04-11T22:44:38.817389+00:00d” ": "2019-04-11T22:44:38.817389+00:00", "state": "unavailable"}, {"attributes": {"friendly_name": "Samsun TV salotto", "supported_features": 18233}, “上下文”:{“id”:“5d25a73d6ca5455bb09724dfe6bda2d6”,“parent_id”:nu ll,“user_id”:null},“entity_id”:“media_player.samsungsalotto”,“last_changed”:“2019-04-14T13:43:45.020455+00:00”,“last_updated”:“2019-04-14T13: 43:45.020455+00:00", "state": "off"}, {"attributes": {"friendly_name": "更新可用", "release_notes": "https://www.home-assistant.io/latest-release-notes/"}, "context": {" id”:“ca231b332d9943268ba730dd058f49da”,“parent_id”:null,“user_id”:null},“entity_id”:“updater.updater”,“last_changed”:“2019-04-11T23:44:29.314457+00:00”, "last_updated": "2019-04-11T23:44:29.314457+00:00", "state": "0.91.3"}]

块引用

【问题讨论】:

  • 我建议你看看Retrofit
  • 好的,我已经编辑过了

标签: android okhttp3 okhttp


【解决方案1】:

使用 Gson 库,在 Postman 中检查您的响应模型,创建一个适当的 DataModel 并将其与 Gson 像这样映射

YourModel model = new Gson().fromJson(response, YourModel.class);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-15
    • 2019-12-12
    • 2016-12-12
    • 1970-01-01
    • 1970-01-01
    • 2017-08-27
    • 1970-01-01
    • 2016-08-20
    相关资源
    最近更新 更多