Flawedspirit Posted December 24, 2016 Posted December 24, 2016 I'm trying to print strings derived from some JSON in my en_US.lang file to notify the player about updates to a mod. However, when the event triggers, the game CTDs and prints a rather non-helpful error: ---- Minecraft Crash Report ---- // Shall we play a game? Time: 12/24/16 5:17 PM Description: Unexpected error com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 at com.google.gson.internal.Streams.parse(Streams.java:56) at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:54) at net.minecraft.util.JsonUtils.gsonDeserialize(JsonUtils.java:453) at net.minecraft.util.JsonUtils.gsonDeserialize(JsonUtils.java:468) at net.minecraft.util.text.ITextComponent$Serializer.jsonToComponent(ITextComponent.java:279) at com.flawedspirit.sandboxmod.util.UpdateChecker.onTick(UpdateChecker.java:66) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_UpdateChecker_onTick_ClientTickEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) at net.minecraftforge.fml.common.FMLCommonHandler.onPostClientTick(FMLCommonHandler.java:344) at net.minecraft.client.Minecraft.runTick(Minecraft.java:1948) at net.minecraft.client.Minecraft.runGameLoop(Minecraft.java:1118) at net.minecraft.client.Minecraft.run(Minecraft.java:406) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 1 at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1505) at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1386) at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:572) at com.google.gson.stream.JsonReader.peek(JsonReader.java:414) at com.google.gson.internal.Streams.parse(Streams.java:42) ... 25 more A detailed walkthrough of the error, its code path and all known details is as follows: --------------------------------------------------------------------------------------- -- Head -- Thread: Client thread Stacktrace: at com.google.gson.internal.Streams.parse(Streams.java:56) at com.google.gson.TreeTypeAdapter.read(TreeTypeAdapter.java:54) at net.minecraft.util.JsonUtils.gsonDeserialize(JsonUtils.java:453) at net.minecraft.util.JsonUtils.gsonDeserialize(JsonUtils.java:468) at net.minecraft.util.text.ITextComponent$Serializer.jsonToComponent(ITextComponent.java:279) at com.flawedspirit.sandboxmod.util.UpdateChecker.onTick(UpdateChecker.java:66) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_6_UpdateChecker_onTick_ClientTickEvent.invoke(.dynamic) at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:185) at net.minecraftforge.fml.common.FMLCommonHandler.onPostClientTick(FMLCommonHandler.java:344) -- Affected level -- Details: Level name: MpServer All players: 1 total; [EntityPlayerSP['Player437'/245, l='MpServer', x=-301.14, y=63.00, z=-597.66]] Chunk stats: MultiplayerChunkCache: 625, 625 Level seed: 0 Level generator: ID 00 - default, ver 1. Features enabled: false Level generator options: Level spawn location: World: (105,64,-40), Chunk: (at 9,4,8 in 6,-3; contains blocks 96,0,-48 to 111,255,-33), Region: (0,-1; contains chunks 0,-32 to 31,-1, blocks 0,0,-512 to 511,255,-1) Level time: 1157961 game time, 13000 day time Level dimension: 0 Level storage version: 0x00000 - Unknown? Level weather: Rain time: 0 (now: false), thunder time: 0 (now: false) Level game mode: Game mode: creative (ID 1). Hardcore: false. Cheats: false Forced entities: 85 total; [EntitySheep['Sheep'/384, l='MpServer', x=-246.77, y=64.00, z=-519.50], EntityRabbit['Rabbit'/398, l='MpServer', x=-252.89, y=63.00, z=-674.95], EntityRabbit['Rabbit'/399, l='MpServer', x=-281.79, y=63.00, z=-653.79], EntityRabbit['Rabbit'/400, l='MpServer', x=-275.44, y=64.92, z=-643.50], EntityRabbit['Rabbit'/401, l='MpServer', x=-265.16, y=64.00, z=-663.97], EntityCreeper['Creeper'/403, l='MpServer', x=-298.23, y=24.00, z=-652.57], EntityRabbit['Rabbit'/404, l='MpServer', x=-297.99, y=66.00, z=-649.04], EntityRabbit['Rabbit'/405, l='MpServer', x=-291.55, y=66.00, z=-645.51], EntityRabbit['Rabbit'/406, l='MpServer', x=-248.43, y=64.00, z=-655.19], EntityZombie['Zombie'/410, l='MpServer', x=-250.16, y=45.00, z=-667.33], EntityRabbit['Rabbit'/411, l='MpServer', x=-314.51, y=63.00, z=-540.92], EntitySkeleton['Skeleton'/413, l='MpServer', x=-223.50, y=36.00, z=-644.50], EntityCreeper['Creeper'/416, l='MpServer', x=-229.46, y=26.00, z=-623.32], EntityBat['Bat'/417, l='MpServer', x=-276.75, y=41.05, z=-581.39], EntityBat['Bat'/418, l='MpServer', x=-276.75, y=41.03, z=-581.25], EntityZombie['Zombie'/419, l='MpServer', x=-265.50, y=33.00, z=-602.50], EntitySpider['Spider'/420, l='MpServer', x=-269.50, y=33.00, z=-601.50], EntitySpider['Spider'/421, l='MpServer', x=-271.99, y=33.00, z=-602.99], EntityPlayerSP['Player437'/245, l='MpServer', x=-301.14, y=63.00, z=-597.66], EntityZombie['Zombie'/422, l='MpServer', x=-269.50, y=33.00, z=-603.50], EntityCreeper['Creeper'/423, l='MpServer', x=-269.50, y=33.00, z=-604.50], EntityCreeper['Creeper'/424, l='MpServer', x=-266.50, y=33.00, z=-603.50], EntityCreeper['Creeper'/425, l='MpServer', x=-265.50, y=33.00, z=-602.50], EntityBat['Bat'/430, l='MpServer', x=-224.81, y=30.93, z=-659.97], EntitySkeleton['Skeleton'/431, l='MpServer', x=-245.50, y=48.00, z=-639.50], EntityZombie['Zombie'/432, l='MpServer', x=-233.50, y=36.00, z=-653.50], EntityBat['Bat'/305, l='MpServer', x=-367.53, y=44.33, z=-537.45], EntityCreeper['Creeper'/433, l='MpServer', x=-239.50, y=48.00, z=-646.50], EntitySkeleton['Skeleton'/434, l='MpServer', x=-281.30, y=45.00, z=-602.30], EntityCreeper['Creeper'/435, l='MpServer', x=-283.09, y=45.00, z=-603.04], EntityCreeper['Creeper'/436, l='MpServer', x=-279.93, y=45.00, z=-604.51], EntityBat['Bat'/309, l='MpServer', x=-360.50, y=27.10, z=-567.25], EntitySkeleton['Skeleton'/437, l='MpServer', x=-285.15, y=44.00, z=-596.19], EntityZombie['Zombie'/438, l='MpServer', x=-277.30, y=45.00, z=-605.08], EntityZombie['Zombie'/439, l='MpServer', x=-286.20, y=45.00, z=-595.49], EntityZombie['Zombie'/440, l='MpServer', x=-284.70, y=45.00, z=-604.32], EntityZombie['Zombie'/441, l='MpServer', x=-279.97, y=45.00, z=-605.49], EntityCreeper['Creeper'/442, l='MpServer', x=-285.77, y=45.00, z=-597.04], EntityRabbit['Rabbit'/315, l='MpServer', x=-336.48, y=65.28, z=-610.04], EntityCreeper['Creeper'/443, l='MpServer', x=-284.07, y=45.00, z=-604.57], EntityCreeper['Creeper'/444, l='MpServer', x=-279.23, y=47.00, z=-592.50], EntitySpider['Spider'/445, l='MpServer', x=-274.09, y=33.00, z=-605.09], EntityRabbit['Rabbit'/318, l='MpServer', x=-332.96, y=63.00, z=-554.64], EntitySpider['Spider'/446, l='MpServer', x=-272.50, y=33.00, z=-601.50], EntityCreeper['Creeper'/319, l='MpServer', x=-366.50, y=45.00, z=-522.50], EntitySkeleton['Skeleton'/447, l='MpServer', x=-277.70, y=48.00, z=-594.49], EntityCreeper['Creeper'/320, l='MpServer', x=-365.50, y=42.00, z=-538.50], EntitySkeleton['Skeleton'/448, l='MpServer', x=-258.50, y=34.00, z=-621.50], EntityZombie['Zombie'/321, l='MpServer', x=-343.49, y=36.00, z=-560.20], EntityZombie['Zombie'/449, l='MpServer', x=-268.50, y=35.00, z=-613.24], EntitySkeleton['Skeleton'/322, l='MpServer', x=-380.66, y=46.00, z=-526.85], EntitySkeleton['Skeleton'/450, l='MpServer', x=-271.50, y=34.00, z=-613.50], EntityZombie['Zombie'/323, l='MpServer', x=-380.50, y=43.00, z=-521.80], EntitySkeleton['Skeleton'/451, l='MpServer', x=-266.50, y=34.00, z=-613.50], EntityCreeper['Creeper'/324, l='MpServer', x=-370.50, y=47.00, z=-524.50], EntityRabbit['Rabbit'/452, l='MpServer', x=-259.99, y=63.00, z=-547.55], EntityBat['Bat'/326, l='MpServer', x=-368.49, y=43.05, z=-539.19], EntityBat['Bat'/459, l='MpServer', x=-267.25, y=46.20, z=-564.62], EntitySheep['Sheep'/460, l='MpServer', x=-262.28, y=64.00, z=-560.57], EntityBat['Bat'/461, l='MpServer', x=-252.75, y=19.99, z=-593.58], EntitySkeleton['Skeleton'/464, l='MpServer', x=-238.30, y=30.07, z=-614.30], EntityCreeper['Creeper'/465, l='MpServer', x=-229.50, y=27.00, z=-620.50], EntityRabbit['Rabbit'/466, l='MpServer', x=-228.49, y=70.00, z=-610.48], EntityRabbit['Rabbit'/468, l='MpServer', x=-258.79, y=65.24, z=-587.72], EntityRabbit['Rabbit'/469, l='MpServer', x=-261.81, y=64.15, z=-587.43], EntityRabbit['Rabbit'/355, l='MpServer', x=-305.95, y=65.00, z=-673.09], EntityZombie['Zombie'/357, l='MpServer', x=-362.65, y=30.00, z=-631.65], EntityBat['Bat'/358, l='MpServer', x=-349.53, y=67.10, z=-640.51], EntityCreeper['Creeper'/359, l='MpServer', x=-340.50, y=34.00, z=-665.50], EntityRabbit['Rabbit'/360, l='MpServer', x=-361.46, y=76.00, z=-655.03], EntitySpider['Spider'/361, l='MpServer', x=-354.70, y=61.00, z=-655.15], EntityRabbit['Rabbit'/362, l='MpServer', x=-307.82, y=66.00, z=-645.98], EntityRabbit['Rabbit'/364, l='MpServer', x=-375.16, y=69.00, z=-597.91], EntitySheep['Sheep'/492, l='MpServer', x=-233.98, y=62.37, z=-549.85], EntityCreeper['Creeper'/371, l='MpServer', x=-247.50, y=26.00, z=-554.50], EntityCreeper['Sir Charles Wingate III'/246, l='MpServer', x=-290.29, y=63.00, z=-593.67], EntityItemFrame['entity.ItemFrame.name'/247, l='MpServer', x=-294.50, y=63.50, z=-594.03], EntitySkeleton['Skeleton'/503, l='MpServer', x=-223.58, y=58.00, z=-608.50], EntityItemFrame['entity.ItemFrame.name'/248, l='MpServer', x=-293.97, y=63.50, z=-593.50], EntityItemFrame['entity.ItemFrame.name'/249, l='MpServer', x=-294.50, y=63.50, z=-592.97], EntitySheep['Sheep'/377, l='MpServer', x=-227.36, y=63.00, z=-525.82], EntityItemFrame['entity.ItemFrame.name'/250, l='MpServer', x=-295.03, y=63.50, z=-593.50], EntitySheep['Sheep'/381, l='MpServer', x=-230.68, y=63.00, z=-531.48], EntitySheep['Sheep'/382, l='MpServer', x=-226.62, y=64.00, z=-541.49], EntityCow['Cow'/383, l='MpServer', x=-235.93, y=63.00, z=-532.55]] Retry entities: 0 total; [] Server brand: fml,forge Server type: Integrated singleplayer server Stacktrace: at net.minecraft.client.multiplayer.WorldClient.addWorldInfoToCrashReport(WorldClient.java:451) at net.minecraft.client.Minecraft.addGraphicsAndWorldToCrashReport(Minecraft.java:2779) at net.minecraft.client.Minecraft.run(Minecraft.java:435) at net.minecraft.client.main.Main.main(Main.java:118) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) at net.minecraft.launchwrapper.Launch.main(Launch.java:28) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) at GradleStart.main(GradleStart.java:26) -- System Details -- Details: Minecraft Version: 1.10.2 Operating System: Windows 10 (amd64) version 10.0 Java Version: 1.8.0_111, Oracle Corporation Java VM Version: Java HotSpot(TM) 64-Bit Server VM (mixed mode), Oracle Corporation Memory: 654869312 bytes (624 MB) / 1921515520 bytes (1832 MB) up to 4761059328 bytes (4540 MB) JVM Flags: 0 total; IntCache: cache: 0, tcache: 0, allocated: 13, tallocated: 95 FML: MCP 9.32 Powered by Forge 12.18.2.2099 7 mods loaded, 7 mods active States: 'U' = Unloaded 'L' = Loaded 'C' = Constructed 'H' = Pre-initialized 'I' = Initialized 'J' = Post-initialized 'A' = Available 'D' = Disabled 'E' = Errored UCHIJAAAA mcp{9.19} [Minecraft Coder Pack] (minecraft.jar) UCHIJAAAA FML{8.0.99.99} [Forge Mod Loader] (forgeSrc-1.10.2-12.18.2.2099.jar) UCHIJAAAA Forge{12.18.2.2099} [Minecraft Forge] (forgeSrc-1.10.2-12.18.2.2099.jar) UCHIJAAAA sandboxmod{1.0.0-alpha} [sandbox Mod] (bin) UCHIJAAAA Waila{1.7.0} [Waila] (Waila-1.7.0-B3_1.9.4.jar) UCHIJAAAA JEI{3.10.0.261} [Just Enough Items] (jei_1.10.2-3.10.0.261.jar) UCHIJAAAA theoneprobe{1.3.3} [The One Probe] (TheOneProbe-1.10-1.3.3-41.jar) Loaded coremods (and transformers): GL info: ' Vendor: 'NVIDIA Corporation' Version: '4.5.0 NVIDIA 369.09' Renderer: 'GeForce GTX 760/PCIe/SSE2' Launched Version: 1.10.2 LWJGL: 2.9.4 OpenGL: GeForce GTX 760/PCIe/SSE2 GL version 4.5.0 NVIDIA 369.09, NVIDIA Corporation GL Caps: Using GL 1.3 multitexturing. Using GL 1.3 texture combiners. Using framebuffer objects because OpenGL 3.0 is supported and separate blending is supported. Shaders are available because OpenGL 2.1 is supported. VBOs are available because OpenGL 1.5 is supported. Using VBOs: Yes Is Modded: Definitely; Client brand changed to 'fml,forge' Type: Client (map_client.txt) Resource Packs: Current Language: English (US) Profiler Position: N/A (disabled) CPU: 4x Intel(R) Core(TM) i5-3570 CPU @ 3.40GHz The JSON in question: info.sandboxmod.update.banner=[{"text":"A new version of "},{"text":"Sandbox Mod","color":"blue"},{"text":" is available.","color":"none"}] info.sandboxmod.update.compareRel=[{"text":"Current version: "},{"text":"%s","color":"dark_red"},{"text":", Newest version: ","color":"none"},{"text":"%s","color":"blue"}] info.sandboxmod.update.compareBeta=[{"text":"Current version: "},{"text":"%s","color":"dark_red"},{"text":", Newest version: ","color":"none"},{"text":"%s","color":"gold"}] info.sandboxmod.update.buttons=[{"text":"["},{"text":"Changelog","color":"blue","clickEvent":{"action":"open_url","value":"%s"}},{"text":"] [","color":"none"},{"text":"Download","color":"blue","clickEvent":{"action":"open_url","value":"%s"}},{"text":"]","color":"none"}] It's all rather opaque-looking, but JSONLint confirms it's valid, so the code itself isn't the issue. The update checker that actually requests the aforementioned JSON: @SubscribeEvent(priority = EventPriority.NORMAL, receiveCanceled = true) public void onTick(TickEvent.ClientTickEvent event) { if(!Reference.IS_DEV && ConfigHandler.enableUpdateChecking) { EntityPlayer player = Minecraft.getMinecraft().thePlayer; if(!notified && Minecraft.getMinecraft().thePlayer != null) { ticksBeforeNotify++; if(ticksBeforeNotify >= 200) { if(!notified) { player.addChatComponentMessage(ITextComponent.Serializer.jsonToComponent("info." + Reference.MODID + ".update.banner")); if(Reference.UPDATE_TYPE == VersionType.RELEASE) { player.addChatComponentMessage(ITextComponent.Serializer.jsonToComponent(String.format("info." + Reference.MODID + ".update.compareRel", Reference.VERSION, Reference.LATEST_VERSION))); } else { player.addChatComponentMessage(ITextComponent.Serializer.jsonToComponent(String.format("info." + Reference.MODID + ".update.compareBeta", Reference.VERSION, Reference.LATEST_VERSION))); } player.addChatComponentMessage(ITextComponent.Serializer.jsonToComponent(String.format("info." + Reference.MODID + ".update.buttons", Reference.CHANGELOG_URL, Reference.DOWNLOAD_URL))); notified = true; ticksBeforeNotify = 0; } } } } } After setting a breakpoint where the train goes off the rails (JsonUtils:468) and stepping through the process, it looks like somewhere in or around the gsonDeserialize method, it's returning JsonScope.EMPTY_DOCUMENT, and almost immediately after that, it leaves mainline processing and enters exception handling until finally reaching all the way to the top and telling Minecraft to end itself. So my question is: is this implying that there's an issue reading the file itself, or is all this me misinterpreting it/a red herring? There is a LOT of stuff that goes on in the background to read this file, and it gets confusing. Another note: I edit the lang files in Sublime Text 3 (or right in Eclipse if I feel like it), in case that helps determine if it's an encoding issue or something. Quote
Flawedspirit Posted December 24, 2016 Author Posted December 24, 2016 I copied and pasted each line into http://jsonlint.com, and they all came up as "valid json" is bright green letters. Is that site wrong, then? I see it linked to all over this site. Also, what do I need to do to achieve the same result then? Full disclosure: I looked to Actually Additions' 1.10.2 branch on Github to find out how that mod does the same thing (thank you/sorry Ellpeck!) and it's near identical to how I do it here. Quote
Jay Avery Posted December 24, 2016 Posted December 24, 2016 I don't know what you were pasting into JSONLint, but I don't think it was the text you showed... Quote
Flawedspirit Posted December 24, 2016 Author Posted December 24, 2016 That's not part of the JSON that is being asked for. That's the tag in my en_US.lang. So I'm working under incorrect assumptions about what the "ITextComponent.Serializer.jsonToComponent" does vis-a-vis the mod's lang files, so it looks like I'll go off and find out how to parse a particular entry in a lang file. Thanks. Quote
jeffryfisher Posted December 25, 2016 Posted December 25, 2016 I copied and pasted each line into http://jsonlint.com Aha! Try pasting each JSON file into jsonlint. Quote The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.