Jump to content

[1.10.2] MalformedJsonException with valid JSON in lang file


Recommended Posts

Posted

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:

 

 

  Reveal hidden contents

 

 

The JSON in question:

 

  Reveal hidden contents

 

 

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:

 

 

  Reveal hidden contents

 

 

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.

Posted

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.

Posted

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.

Posted
  Quote
I copied and pasted each line into http://jsonlint.com

 

Aha! Try pasting each JSON file into jsonlint.

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.

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.