二つ、Javaは、処理パラメータ(JSONObject、getJSONArray等)に戻ります

前記取得された値は、リターン・パラメータ・フォーマットに基づいて

1. ResponseEntity <文字列> responseEntityオブジェクトを与えます

インポートorg.springframework.http.ResponseEntity; 

得到ResponseEntityの<string> responseEntity对象


 <200 

{
     "コード":0  "データ" :{
         "リスト" :[ 
            {
                 "量":0  "auditTime": ""  "channelType": ""  "CREATETIME": "2019年8月13日夜05時01分55秒"  "creditStatus": ""  "編集": "fundsStatus":""  "ID":372  "IDNO": "" "lendRequestId":0  "モバイル": "13289989000"  "名前": "客户姓名"  "soinsStatus": ""  "状態":0  "stateText": ""  "viewStateText":0 
            } 
        ] 
    }、
     "マスク": "251eeedb-e214-47c6-aa0c-3eb6c7b67aa0"  "MSG": "成功"  "タイムスタンプ":1566089672 
} 

、{サーバー = [Tengine / 2.1.1]、日付= [日、 2019年8月18日00:54:32 GMT]のContent-Type = [アプリケーション/ JSON;のcharset = UTF-8]、コンテンツ長= [412]、コネクション= [キープアライブ]}>

ResponseEntity <文字列> responseEntityオブジェクト、身体の一部を取得し、身体のフォーマット文字列ではないJSON

コンテンツresponseEntity.getBody =文字列(); 


コンテンツ出力:
{
     "コード":0  "データ" :{
         "リスト" :[ 
            {
                 "量":0  "auditTime": ""  "channelType": ""  "CREATETIME": "2019年8月13日17: 1時55"分 "creditStatus": ""  "編集": "fundsStatus": ""  "ID":372  "IDNO": "" "lendRequestId":0  "モバイル": "13243345566"  "名": "客户姓名" "soinsStatus": ""  "状態":0  "stateText": ""  "viewStateText":0 
            } 
        ] 
    }、
     "マスク": "251eeedb-e214-47c6-aa0c-3eb6c7b67aa0"  "MSG"。 "成功"  "タイムスタンプ":1566089672 
}

3.フィールド値のID、名前、携帯電話などのリストを取得

JSONに3.1 JSON文字列オブジェクト
// のJSON JSONに文字列オブジェクト 
JSONObject JSON = JSONObject.parseObject(コンテンツ)。

  輸出

{
     "MSG": "成功"  "コード":0  "データ" :{
         "リスト" :[ 
            {
                 "量":0  "soinsStatus": ""  "viewStateText":0  "編集": "モバイル": "12324435555"  "channelType": ""  "creditStatus": ""  "fundsStatus": ""  "IDNO ":"」  "auditTime": ""  "CREATETIME": "2019年8月13日17時01分55秒" "stateText": ""  "名前": "客户姓名"  "ID" 372  "lendRequestId":0  "状態":0 
            } 
        ] 
    }、
     "マスク":「251eeedb-e214-47c6-aa0c -3eb6c7b67aa0"  "タイムスタンプ":1566089672 
}

 3.2データ抽出部

// オブジェクトデータの一部除去 
JSONObjectデータ= json.getJSONObject(「データ」 );

輸出

{
     "リスト" :[ 
        {
             "量":0  "soinsStatus": ""  "viewStateText":0  "編集": "モバイル": "13234444555"  "channelType": ""  "creditStatus" : ""  "fundsStatus": ""  "IDNO": ""  "auditTime": ""  "CREATETIME": "2019年8月13日午後05時01分55秒" "stateText": ""  "名": "客户姓名"  "ID":372 "lendRequestId":0  "状態":0 
        } 
    ] 
}

3.3データアレイは、括弧[]、そうタイプJSONArrayにオブジェクトとリストの内容を含みます

// 変換型オブジェクトJSONArray 
JSONArray jsonArray = data.getJSONArray( "リスト" )。

出力;

[ 
    {
         "量":0  "soinsStatus": ""  "viewStateText":0  "編集": "モバイル": "13234444555"  "channelType": ""  "creditStatus": ""  " fundsStatus ":"」 "IDNO": ""  "auditTime": ""  "CREATETIME": "2019年8月13日17時〇一分55秒"  "stateText": "" "名前": "客户姓名"  "ID":372  "lendRequestId":0  "状態":0
    } 
]

3.4それは、複数のアレイである場合

jsonArray.getJSONObject(インデックス)
ランダムアレイ選択// 
JSONObject idInfo = jsonArray.getJSONObject(RANDOMINTEGER(0 、jsonArray.size()))。
文字列ID = idInfo.getString( "ID")。

 

おすすめ

転載: www.cnblogs.com/chushujin/p/11371450.html