[英]Reading multiple parameters of JSON objects in java
大家好,我在閱讀這個文件時遇到了問題,誰能建議我如何使用模型名稱和標語以及這個模型的變體代碼來閱讀這個文件。 我是使用 java 讀取 json 的新手,每當我嘗試讀取獲取此異常時,即線程“main”中的異常 java.lang.ClassCastException: class org.json.simple.JSONObject cannot be cast to class org.json.simple .JSONArray(org.json.simple.JSONObject 和 org.json.simple.JSONArray 位於加載程序“app”的未命名模塊中)對此有任何參考嗎?
{
"models": {
"IN": [
{
"modelName": "Inter",
"modelTagline": "A classic roadster",
"models": [
{
"ID": "Inter-0",
"engineCapacity": "Test",
"imageUrl": "INT.png",
"mailCCBTR": "",
"mailToBTR": "",
"mailerBikeImageBTR": "orange.jpg",
"modelCodeBTR": "XYZ23",
"name": "Int 0",
"power": "47 Bhp",
"showCatalogue": true,
"showInDealer": false,
"showInREPrime": true,
"tagLine": "A classic roadster",
"torque": "52 Nm",
"variants": [
{
"highlights": [
"LOREM IPSUM",
"",
"",
""
],
"id": "int 50",
"imageUrl": "3F_GTred_000.png",
"name": "red",
"showBookNow": false,
"showConfigureNow": true,
"showInDealer": false,
"showInREPrime": true,
"tankColor": "Red",
"tankImage": "Red_01.png",
"variantCode": "AVC",
"webp": "000.webp",
"webp-mobile-1x": "3.webp",
"webp-mobile-2x": "2.webp"
},
{
"highlights": [
"LOREM IPSUM",
"",
"",
""
],
"id": "int 50",
"imageUrl": "V000.png",
"name": "Blue",
"showBookNow": false,
"showConfigureNow": true,
"showInDealer": false,
"showInREPrime": true,
"tankColor": "Blue",
"tankImage": "Blue_01.png",
"variantCode": "SADSAD32",
"webp": "F.webp",
"webp-mobile-1x": "LOREM IPSUM.webp",
"webp-mobile-2x": "LOREM IPSUM.webp"
},
{
"highlights": [
"LOREM IPSUM",
"",
"",
""
],
"id": "int 50",
"imageUrl": "80.png",
"name": "Crush",
"showBookNow": false,
"showConfigureNow": true,
"showInDealer": false,
"showInREPrime": true,
"tankColor": "Crush",
"tankImage": "h_01.png",
"variantCode": "56565SDGFS",
"webp": "h_000.webp",
"webp-mobile-1x": "LOREM IPSUM.webp",
"webp-mobile-2x": "LOREM IPSUM.webp"
},
{
"highlights": [
"It's a blast to ride on twisty back roads, highways or the urban jungle, with equal ease and grace, for novices and experienced riders alike",
"",
"",
""
],
"id": "inter50",
"imageUrl": "00.png",
"name": "Downtown Drag",
"showBookNow": false,
"showConfigureNow": true,
"showInDealer": false,
"showInREPrime": true,
"tankColor": "Downtown Drag",
"tankImage": "01.png",
"variantCode": "lkasdsd",
"webp": "int 500.webp",
"webp-mobile-1x": "int 500.webp",
"webp-mobile-2x": "test.webp"
},
{
"highlights": [
"It's a blast to ride on twisty back roads, highways or the urban jungle, with equal ease and grace, for novices and experienced riders alike",
"",
"",
""
],
"id": "int 50",
"imageUrl": "k_000.png",
"name": "Sunset Strip",
"showBookNow": false,
"showConfigureNow": true,
"showInDealer": false,
"showInREPrime": true,
"tankColor": "Sunset Strip",
"tankImage": "Black_01.png",
"variantCode": "AFDF23",
"webp": "TEST.webp",
"webp-mobile-1x": "TEST3.webp",
"webp-mobile-2x": "T.webp"
}
]
}
大家好,我在閱讀這個文件時遇到了問題,誰能建議我如何使用模型名稱和標語以及這個模型的變體代碼來閱讀這個文件。 我是使用 java 讀取 json 的新手,每當我嘗試讀取獲取此異常時,即線程“main”中的異常 java.lang.ClassCastException: class org.json.simple.JSONObject cannot be cast to class org.json.simple .JSONArray(org.json.simple.JSONObject 和 org.json.simple.JSONArray 位於加載程序“app”的未命名模塊中)
看起來這個 json 沒有完成。 如果我有誤解,您可以上傳 .json 文件。 如果這個json是全部,請在json末尾附加“]}]}}”。 祝你好運。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.