それは質問が一日中苦しめ、そして良い抑うつ気分がついにリリースされ、最後に引退し、それが記録されるべきものではないと思い座るだけです。
すべてのJSON文字列の最初のデータへの外部ネットワークインタフェースから返された、私の友人が知りたい形式上の外観にJSONパーサーにコピーすることができます。https://www.json.cn/#
{ "ステータス": "真"、 "biz_result":[{ "PartyFunctionCode": "NBEPORT"、 "PartyIdentifier": "コンテナ"、 "PartyName": "宁波电子口岸"、 "ManifestInfo":[{ "LadingBillNumber" : "COSU6224023460B"、 "ShippingCompanyName": ""、 "VesselNameCode": "COSCO営口"、 "VesselName": "COSCO営口"、 "PlaceOfLoading": ""、 "PlaceOfDischarge": ""、 "VoyageNumber": "130W 」、 "DirectionCode": ""、 "VesselCallNumber": ""、 "IMO番号": ""}]、 "ContainerInfo":[{ "ContainerNumber": "FCIU9840537"、 "ContainerOperator": "COS"、 "SealNumber" : "11374417"、」CodeOfSizeAndType ":" " "ContainerLoadingStatusCode": ""、 "ContainerTareWeight": "0"、 "TransportMeansType": ""、 "VehicleNumber": ""、 "ContainerStatusInformation":[{ "ImExIdentifier": ""、" TransportStatusCode ":" 码头已经放行 " "TransportStatusNameEN": ""、 "DateOrTimeOrPeriod": "2019年10月25日午後五時34分49秒"、 "TimeZoneIdentifier": "PRC"、 "PlaceLocationQualifier": "NBEPORT"、" PlaceOrLocationIdentification ":"」、 "PlaceOrLocation": ""、 "備考": "宁波电子口岸"、 "ステータス": "DOCKPASS"、 "EVENTNAME": ""}、{ "ImExIdentifier": "E"、 "TransportStatusCode" :」重箱进港 " "TransportStatusNameEN": ""、 "DateOrTimeOrPeriod": "2019年10月24日夜1時29分00秒"、 "TimeZoneIdentifier": "PRC"、 "PlaceLocationQualifier": "NBEPORT"、 "PlaceOrLocationIdentification":" BLCT3" 、 "PlaceOrLocation": "北仑四期码头"、 "備考": "宁波电子口岸"、 "ステータス": "INOUT"、 "EVENTNAME": "进港"}、{ "ImExIdentifier": "E" 、 "TransportStatusCode": "海关放行"、 "TransportStatusNameEN": ""、 "DateOrTimeOrPeriod": "2019年10月25日11時04分37秒"、 "TimeZoneIdentifier": "PRC"、 "PlaceLocationQualifier": "NBEPORT"、 "PlaceOrLocationIdentification": ""、 "PlaceOrLocation": ""、 "備考""寧波電子ポート"、 "ステータス": "CUSPASS"、 "EVENTNAME": "通関"}、{ "ImExIdentifier": ""、 "TransportStatusCode": "27301ローディングマニフェストデータ送信が成功した"、「TransportStatusNameENを。 ":" "" DateOrTimeOrPeriod ":" 2019年10月31日夜01時44分41秒 "" TimeZoneIdentifier ":" PRC "" PlaceLocationQualifier ":" NBEPORT "" PlaceOrLocationIdentification ":" "" PlaceOrLocation ":" "" 備考 ":" 寧波電子ポート "" ステータス ":" MFT "" EVENTNAME ":" ロードマニフェスト "}、{" ImExIdentifier ":" E "" TransportStatusCode ":" ボード上の重い箱」、 "TransportStatusNameEN": ""、 "DateOrTimeOrPeriod": "2019年11月1日夜四時13分00秒"、 "TimeZoneIdentifier":"PRC"、 "PlaceLocationQualifier": "NBEPORT"、 "PlaceOrLocationIdentification": "BLCT3"、 "PlaceOrLocation": "北仑四期码头"、 "備考": "宁波电子口岸"、 "ステータス": "LOAD"、」 EVENTNAME ":" 装船 "}、{" ImExIdentifier ":"」、 "TransportStatusCode": "开船"、 "TransportStatusNameEN": ""、 "DateOrTimeOrPeriod": "2019年11月1日夜十時○○分00秒"、 "TimeZoneIdentifier": "PRC"、 "PlaceLocationQualifier": "NBEPORT"、 "PlaceOrLocationIdentification": "BLCT3"、 "PlaceOrLocation": "北仑四期码头"、 "備考": "宁波电子口岸"、 "ステータス":」バース " "EVENTNAME": "离港"}]}]}、{ "PartyFunctionCode":"NBEPORT」、 "PartyIdentifier": "コンテナ"、 "PartyName": "宁波电子口岸"、 "ManifestInfo":[{ "LadingBillNumber": "COSU6224023460A"、 "ShippingCompanyName": ""、 "VesselNameCode": "COSCO営口" 、 "VesselName": "COSCO営口"、 "PlaceOfLoading": ""、 "PlaceOfDischarge": ""、 "VoyageNumber": "130W"、 "DirectionCode": ""、 "VesselCallNumber": ""、 "IMO番号": ""}]、 "ContainerInfo":[{ "ContainerNumber": "FCIU9840537"、 "ContainerOperator": "COS"、 "SealNumber": "11374417"、 "CodeOfSizeAndType": ""、 "ContainerLoadingStatusCode": ""、」ContainerTareWeight ":" 0" 、 "TransportMeansType": ""、 "VehicleNumber": ""、 "ContainerStatusInformation":[{ "ImExIdentifier": ""、 "TransportStatusCode": "码头已经放行"、 "TransportStatusNameEN": "" 、 "DateOrTimeOrPeriod": "2019年10月25日夜05時34分49秒"、 "TimeZoneIdentifier": "PRC"、 "PlaceLocationQualifier": "NBEPORT"、 "PlaceOrLocationIdentification": ""、 "PlaceOrLocation": ""、 "備考":" 宁波电子口岸」、 "ステータス": "DOCKPASS"、 "EVENTNAME": ""}、{ "ImExIdentifier": "E"、 "TransportStatusCode": "重箱进港"、 "TransportStatusNameEN": ""、 "DateOrTimeOrPeriod":」2019年10月24日夜一時29分○○秒" 、 "TimeZoneIdentifier": "PRC"、 "PlaceLocationQualifier": "NBEPORT"、 "PlaceOrLocationIdentification": "BLCT3"、 "PlaceOrLocation": "北仑四期码头"、 "備考" "宁波电子口岸"、 "ステータス": "INOUT"、 "EVENTNAME": "进港"}、{ "ImExIdentifier": "E"、 "TransportStatusCode": "海关放行"、 "TransportStatusNameEN": ""、 "DateOrTimeOrPeriod": "2019年10月25日午前11時04分27秒"、 "TimeZoneIdentifier": "PRC"、 "PlaceLocationQualifier": "NBEPORT"、 "PlaceOrLocationIdentification": ""、 "PlaceOrLocation": ""、 "備考" : "宁波电子口岸"、 "ステータス": "CUSPASS"、 "EVENTNAME":」海关放行 "}、{" ImExIdentifier ":" " "TransportStatusCode": "27301装载舱单数据传输成功"、 "TransportStatusNameEN": ""、 "DateOrTimeOrPeriod":" 2019年10月31日夜1時44分41秒」、 "TimeZoneIdentifier": "PRC"、 "PlaceLocationQualifier": "NBEPORT"、 "PlaceOrLocationIdentification": ""、 "PlaceOrLocation": ""、 "備考": "宁波电子口岸"、 "ステータス": "MFT"、 "EVENTNAME": "装载舱单"}、{ "ImExIdentifier": "E"、 "TransportStatusCode": "重箱装船"、 "TransportStatusNameEN": ""、 "DateOrTimeOrPeriod": "2019年11月1日午後4時13分:00" 、 "TimeZoneIdentifier": "PRC"、 "PlaceLocationQualifier": "NBEPORT"、」PlaceOrLocationIdentification ":" BLCT3 "" PlaceOrLocation ":" 北侖4つのドック "" 備考 ":" 寧波Eポート "" ステータス ":" LOAD "" EVENTNAME ":"}]}]}」出荷] 、 "エラー": ""}
ここでは廃棄物に多くの時間や効果なし、間違った方法を使用していると推定さは、この方法の成功に直接貼付層による剥離層へalibabのしたい、このJSON、とfastjsonパッケージ中に。
まず第一に、私は、ここでは、JSON形式によると、1つのレベルの書き込みまで比較的単純な最初のビルドのエンティティクラスですでしょう、それが直接コードに装着されています。(GETSETおよびコンストラクタ私は少しあまりにも多くのスペースを入れません)
1 インポートcom.fasterxml.jackson.annotation.JsonIgnoreProperties。 2 インポートしたjava.io.Serializable。 3 インポートはjava.util.List; 4 5 @JsonIgnoreProperties(ignoreUnknown = 真) 6 @SuppressWarnings( "シリアル" ) 7 パブリック クラス結果を実装シリアライズ{ 8つの 9 プライベート文字列のステータス。 10 プライベートリスト<biz_result> biz_result。 11 プライベート文字列のエラー。
1 インポートcom.fasterxml.jackson.annotation.JsonIgnoreProperties。 2 インポートしたjava.io.Serializable。 3 インポートはjava.util.List; 4 5 @JsonIgnoreProperties(ignoreUnknown = 真) 6 @SuppressWarnings( "シリアル" ) 7つの パブリック クラス biz_resultの実装シリアライズ{ 8 プライベートストリングPartyFunctionCode。 9 プライベート文字列PartyIdentifier。 10 プライベート文字列PartyName。 11 プライベートリスト<ManifestInfo>ManifestInfo; 12 プライベートリスト<ContainerInfo> ContainerInfo。
1 インポートcom.fasterxml.jackson.annotation.JsonIgnoreProperties。 2 インポートしたjava.io.Serializable。 3 4 @JsonIgnoreProperties(ignoreUnknown = 真) 5 @SuppressWarnings( "シリアル" ) 6 パブリック クラス ManifestInfo 実装シリアライズ{ 7 プライベートストリングLadingBillNumber。 8 プライベート文字列ShippingCompanyName。 9 プライベート文字列VesselNameCode。 10 プライベート文字列VesselName。 11 プライベート文字列PlaceOfLoading; 12 プライベート文字列PlaceOfDischarge。 13 プライベート文字列VoyageNumber。 14 プライベート文字列DirectionCode。 15 プライベート文字列VesselCallNumber。 16 プライベート文字列IMO番号;
1 インポートcom.fasterxml.jackson.annotation.JsonIgnoreProperties。 2 インポートしたjava.io.Serializable。 3 インポートはjava.util.List; 4 5 @JsonIgnoreProperties(ignoreUnknown = 真) 6 @SuppressWarnings( "シリアル" ) 7 パブリック クラス ContainerInfo 実装シリアライズ{ 8 9 プライベートストリングContainerNumber。 10 プライベート文字列ContainerOperator。 11 プライベート文字列SealNumber。 12 プライベート文字列CodeOfSizeAndType; 13 プライベート文字列ContainerLoadingStatusCode。 14 プライベート文字列ContainerTareWeight。 15 プライベート文字列TransportMeansType。 16 プライベート文字列VehicleNumber。 17 プライベートリスト<ContainerStatusInformation> ContainerStatusInformation。
1 インポートcom.fasterxml.jackson.annotation.JsonIgnoreProperties。 2 インポートしたjava.io.Serializable。 3 4 @JsonIgnoreProperties(ignoreUnknown = 真) 5 @SuppressWarnings( "シリアル" ) 6つの パブリック クラス ContainerStatusInformationの実装シリアライズ{ 7 8 プライベートストリングImExIdentifier。 9 プライベート文字列TransportStatusCode。 10 プライベート文字列TransportStatusNameEN。 11 プライベート文字列DateOrTimeOrPeriod。 12 プライベート文字列TimeZoneIdentifier。 13 プライベート文字列PlaceLocationQualifier。 14 プライベート文字列PlaceOrLocationIdentification。 15 プライベート文字列PlaceOrLocation。 16 プライベート文字列備考; 17の プライベート文字列のステータス。 18 プライベート文字列EVENTNAME。
ちょうどそれを折るしないことを考える、私は私が動作するために戻って行くことはありません申し訳ありませんが、それはあまりにも長くはかからないだろうが、私は怠け者です。
建設エンティティクラスが終了した後、私はそれを試みたが、fastjsonのはもはや使用alibab、次のパッケージを使用します。
輸入 net.sf.json.JSONObject;
Mavenの依存関係は次のとおりです。
<依存> <groupIdを> net.sf.json-LIB </ groupIdを> <たartifactId> JSON-libの</たartifactId> <バージョン> 2.4 </ version>の <分類器> jdk15 </クラシファイア> </依存関係>
次のように最終的なコードです。
1 インポートnet.sf.json.JSONArray; 2 インポートnet.sf.json.JSONObject; 3 4。 パブリック クラスTEST02 { 5。 6。 パブリック 静的 ボイドメイン(文字列[]引数){ 7。 8。 ストリングJSON =「これは、上記の長い巨大でありJSONの" ; 9 10 // JSONオブジェクトを取得 11。 jSONObject jsonObject = JSONObject.fromObject(JSON); 12である // そこbiz_resultアレイ得る 13である JSONArray biz_result = jsonObject.getJSONArray(" biz_result " ); 14 // 取得アレイ誰か要素 15 Biz_result.getString biz_resultString =文字列(0 ); 16 // アレイ再度変換JSONオブジェクトに配列における 17。 JSONObject jsonObject1 = JSONObject.fromObject(biz_resultString); 18である // のgetStringによって値を取得し 19。 文字列manifestInfo jsonObject1.getString(= "ManifestInfo" ); 20である // 第1ブラケットJSON形式与える除去 21である 文字列manifestInfo.substringストリング=(1 ;) 22れる 1 -文字サブストリングがsubstring.substring =(0、substring.lengthは();) 23である // JSONを得オブジェクトに変換した後、JSON形式 24 JSONObject JB3 =JSONObject.fromObject(SUBSTRING); 25 // 目的の値を取得します。 図26は、ある 文字列vesselName = jb3.getString( "VesselName" ;) 27 のSystem.out.println(vesselName); 28 29 } 30 }
あなたが書き込みコメントTieshanglaiない場合は、まだコメントを書く習慣を開発する必要があり、私は不快に見えたし、最終的に必要なデータを持っています:
COSCO営口市
あなたが助けることができるならば、それは大丈夫です。
すべてのエラーや提案は、メッセージを残してください。