在Java中读取JSON对象的多个参数
大家好,我在阅读此文件时会出现问题,任何人都可以建议我使用模型名称和标语以及此模型的变体代码读取此文件。我是使用Java在JSON中阅读的新手,每当我想阅读此例外时,IE例外是“ Main” java.lang.lang.classcastexception:class org.json.simple.jsonobject.jsonobject class org.json.json.json.simple 。 有什么参考吗?
{
"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中阅读的新手,每当我想阅读此例外时,IE例外是“ Main” java.lang.lang.classcastexception:class org.json.simple.jsonobject.jsonobject class org.json.json.json.simple 。
Hi guys I am getting issue while reading this file can anyone suggest me how to read this file by using model name and tagline and also variant code of this model. I am new to reading in json using java , whenever I am trying to read getting this exception i.e. Exception in thread "main" java.lang.ClassCastException: class org.json.simple.JSONObject cannot be cast to class org.json.simple.JSONArray (org.json.simple.JSONObject and org.json.simple.JSONArray are in unnamed module of loader 'app')
Any reference for this?
{
"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"
}
]
}
Hi guys I am getting issue while reading this file can anyone suggest me how to read this file by using model name and tagline and also variant code of this model. I am new to reading in json using java , whenever I am trying to read getting this exception i.e. Exception in thread "main" java.lang.ClassCastException: class org.json.simple.JSONObject cannot be cast to class org.json.simple.JSONArray (org.json.simple.JSONObject and org.json.simple.JSONArray are in unnamed module of loader 'app')
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来这个JSON尚未完成。如果我有误解,则可以上传.json文件。如果此json全部,请附加“]}}}”到JSON的结尾。
祝你好运。
looks like this json is not completed. If i have misunderstand, you can upload .json file. If this json is all, please append "]}]}}" to end of json.
Good luck.