Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-120476

"Expected item to be a JsonObject" error abbreviates too heavily

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • None
    • Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w43a, Minecraft 17w43b, Minecraft 17w45a, Minecraft 17w46a, Minecraft 17w48a, Minecraft 18w06a, Minecraft 1.13-pre3, Minecraft 1.13-pre8, Minecraft 1.13-pre10, Minecraft 1.13, Minecraft 18w30b, Minecraft 18w31a, Minecraft 1.13.1, 1.14.4, 1.15 Pre-release 6, 1.15.2, 1.19.3
    • None
    • Windows 7 x64
      java version "1.8.0_101"
      Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
      Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)
    • Confirmed
    • (Unassigned)

      When writing new advancements or recipes and a parsing error occurs and the error "Expected item to be a JsonObject" is thrown, the details of that error are heavily truncated to the point of uselessness:

      [13:56:44] [Server thread/ERROR] [FML]: Parsing error loading built-in advancement harderfarming:recipes/thermometer
      com.google.gson.JsonSyntaxException: Expected item to be a JsonObject, was "min...op"

      What on earth is "min...op"? This makes it hard to locate the error in my JSON file.

      This is due to the following code located in JsonUtils.toString:
      StringUtils.abbreviateMiddle(String.valueOf((Object)json), "...", 10)
      The "10" indicates how long or short the displayed string should be, in this case, 10 characters, of which the "..." counts for 3. The starting and ending quotes then count for 2. That leaves 5 characters from the actual JSON file that can be displayed. This is not nearly enough.

      Suggest raising the value to 15 (to account for the 5 characters that are forced) or 20 (to be less aggressive generally). That would result in:
      (at 15): "minec...kchop"
      (at 20): "minecraft:porkchop"

      15 would be sufficient to locate the error, although difficult to read, while 20 would be sufficient to show the entire string for a majority of items, but also not increase the size of the error message unduly for lengthy issues.

            Unassigned Unassigned
            draco18s Draco Silverwing
            Votes:
            7 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              CHK: