--- title: '把json轉成java物件' disqus: hackmd --- ###### tags: `Ads API` `Google Ads` 把json轉成java物件 === [TOC] ## 筆記目的 大致了解怎麼把API的東西轉乘概念 ## 應用情況 ![](https://i.imgur.com/1rlJXnH.png) ## 程式碼部分 ```java= private void name(String response) { JSONObject object = new JSONObject(response); String kind = object.getString("kind");//kind = abc JSONArray array = object.isNull("owners") ? new JSONArray() : object.getJSONArray("owners"); for (int i = 0; i < array.length(); i++) { JSONObject abc = array.getJSONObject(i); String pId = abc.isNull("Pid") ? "" : abc.getString("Pid"); } } ```