gpt4 book ai didi

java - 格式错误的 json 导致 java.lang.RuntimeException

转载 作者:行者123 更新时间:2023-12-02 01:45:45 25 4
gpt4 key购买 nike

我正在尝试使用 android studio 为 Whatsapp 构建一个简单的贴纸应用程序。我不知道为什么它说有一个邮件格式的 json 文件。这是 logcat 上的错误(可能是其他原因,例如 apk 名称错误或其他错误)

D/AndroidRuntime: Shutting down VM
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.javiermilei.stickers, PID: 5574
java.lang.RuntimeException: Unable to get provider com.javiermilei.stickers.StickerContentProvider: java.lang.RuntimeException: contents.json file has some issues: Use JsonReader.setLenient(true) to accept malformed JSON at line 17 column 10
at android.app.ActivityThread.installProvider(ActivityThread.java:5923)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5490)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5429)
at android.app.ActivityThread.-wrap2(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1564)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6186)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
Caused by: java.lang.RuntimeException: contents.json file has some issues: Use JsonReader.setLenient(true) to accept malformed JSON at line 17 column 10
at com.javiermilei.stickers.StickerContentProvider.readContentFile(StickerContentProvider.java:149)
at com.javiermilei.stickers.StickerContentProvider.getStickerPackList(StickerContentProvider.java:155)
at com.javiermilei.stickers.StickerContentProvider.onCreate(StickerContentProvider.java:90)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1751)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1726)
at android.app.ActivityThread.installProvider(ActivityThread.java:5920)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:5490) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5429) 
at android.app.ActivityThread.-wrap2(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1564) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6186) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) 
Caused by: android.util.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 17 column 10
at android.util.JsonReader.syntaxError(JsonReader.java:1159)
at android.util.JsonReader.checkLenient(JsonReader.java:838)
at android.util.JsonReader.nextInObject(JsonReader.java:660)
at android.util.JsonReader.peek(JsonReader.java:349)
at android.util.JsonReader.hasNext(JsonReader.java:319)
at com.javiermilei.stickers.ContentFileParser.readStickers(ContentFileParser.java:145)
at com.javiermilei.stickers.ContentFileParser.readStickerPack(ContentFileParser.java:106)
at com.javiermilei.stickers.ContentFileParser.readStickerPacks(ContentFileParser.java:47)
at com.javiermilei.stickers.ContentFileParser.parseStickerPacks(ContentFileParser.java:28)
at com.javiermilei.stickers.StickerContentProvider.readContentFile

我找不到这里的错误,据说该文件在第 17 行第 10 列有一个邮件表格(根据 logcat)

{
"android_play_store_link": "",
"ios_app_store_link": "",
"sticker_packs": [
{
"identifier": "1",
"name": "Javier Milei",
"publisher": "QBSLC Inc.",
"tray_image_file": "tray_Milei.png",
"publisher_email":"",
"publisher_website": "",
"privacy_policy_website": "",
"license_agreement_website": "",
"stickers": [
{
"image_file": "01_Milei.webp",
},
{
"image_file": "02_Milei.webp",
},
{
"image_file": "03_Milei.webp",
},
{
"image_file": "04_Milei.webp",
},
{
"image_file": "05_Milei.webp",
},
{
"image_file": "06_Milei.webp",
},
{
"image_file": "07_Milei.webp",
},
{
"image_file": "08_Milei.webp",
},
{
"image_file": "09_Milei.webp",
},
{
"image_file": "10_Milei.webp",
},
{
"image_file": "11_Milei.webp",
},
{
"image_file": "12_Milei.webp",
},
{
"image_file": "13_Milei.webp",
}

]
}
]
}

最佳答案

您可以检查 JSON 是否有效,使用此网站例如:https://jsonformatter.curiousconcept.com/

就您而言,您的贴纸条目中存在无效的逗号。

关于java - 格式错误的 json 导致 java.lang.RuntimeException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53696802/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com