Bug in JSON parsing when in a class/object diagram

0 votes
asked Jun 22, 2022 in Bug by anonymous
edited Jun 23, 2022
I noticed a problem with parsing one of my JSON structures once I pulled it over into a combined UML file (@startuml insead of @startjson). So then I took one of the examples from the plantuml website and recreated the problem. Maybe it is just two levels of objects aren't being parsed correctly?

The log:

plantuml -tsvg broken.obj
l="null": null,
l="true": true,
l="false": false,
l="JSON_Number": [-1, -1.1, "<color:green>TBC"],
l="JSON_String": "a\nb\rc\td <color:green>TBC...",
l="JSON_Object": {
l="{}": {},
l="k_int": 123,
l="k_str": "abc",
l="k_obj": {
l="k": "v"
Error net.sourceforge.plantuml.json.ParseException: Unexpected end of input at 1:209
net.sourceforge.plantuml.json.ParseException: Unexpected end of input at 1:209
    at net.sourceforge.plantuml.json.JsonParser.error(JsonParser.java:493)
    at net.sourceforge.plantuml.json.JsonParser.expected(JsonParser.java:487)
    at net.sourceforge.plantuml.json.JsonParser.readObject(JsonParser.java:254)
    at net.sourceforge.plantuml.json.JsonParser.readValue(JsonParser.java:180)
    at net.sourceforge.plantuml.json.JsonParser.readObject(JsonParser.java:249)
    at net.sourceforge.plantuml.json.JsonParser.readValue(JsonParser.java:180)
    at net.sourceforge.plantuml.json.JsonParser.parse(JsonParser.java:155)
    at net.sourceforge.plantuml.json.JsonParser.parse(JsonParser.java:94)
    at net.sourceforge.plantuml.objectdiagram.command.CommandCreateJson.executeNow(CommandCreateJson.java:129)
    at net.sourceforge.plantuml.objectdiagram.command.CommandCreateJson.executeNow(CommandCreateJson.java:64)
    at net.sourceforge.plantuml.command.CommandMultilines2.execute(CommandMultilines2.java:111)
    at net.sourceforge.plantuml.command.ProtectedCommand.execute(ProtectedCommand.java:54)
    at net.sourceforge.plantuml.AbstractPSystem.executeCommand(AbstractPSystem.java:157)
    at net.sourceforge.plantuml.command.PSystemCommandFactory.executeFewLines(PSystemCommandFactory.java:125)
    at net.sourceforge.plantuml.command.PSystemCommandFactory.createSystem(PSystemCommandFactory.java:108)
    at net.sourceforge.plantuml.PSystemBuilder.createPSystem(PSystemBuilder.java:136)
    at net.sourceforge.plantuml.BlockUml.getDiagram(BlockUml.java:181)
    at net.sourceforge.plantuml.SourceFileReaderAbstract.getGeneratedImages(SourceFileReaderAbstract.java:160)
    at net.sourceforge.plantuml.Run.manageFileInternal(Run.java:517)
    at net.sourceforge.plantuml.Run.processArgs(Run.java:400)
    at net.sourceforge.plantuml.Run.manageAllFiles(Run.java:367)
    at net.sourceforge.plantuml.Run.main(Run.java:202)
You should send a mail to plantuml@gmail.com or post to http://plantuml.com/qa with this log (V1.2022.5)
Error line 18 in file: broken.obj
Some diagram description contains errors

Here is the file contents. Its just an example on the plantuml website but I indented k_obj:

@startuml
allowmixing

title Information Table

json fit {
        "null": null,
        "true": true,
        "false": false,
        "JSON_Number": [-1, -1.1, "<color:green>TBC"],
        "JSON_String": "a\nb\rc\td <color:green>TBC...",
        "JSON_Object": {
                "{}": {},
                "k_int": 123,
                "k_str": "abc",
                "k_obj": {
                        "k": "v"
                }
        },
        "JSON_Array" : [
                [],
                [true, false],
                [-1, 1],
                ["a", "b", "c"],
                ["mix", null, true, 1, {"k": "v"}]
        ]
}

@enduml

1 Answer

0 votes
answered Jun 22, 2022 by The-Lu (63,920 points)
 
Best answer

Hello A.,

You are on: V1.2022.5.

  • Could you upgrade to V1.2022.6 (available from today)
  • Also, could you test:
@startuml
title Frame Information Table

json fit {
   "k_obj": {"k": "v"}
}
@enduml

See also similar issue about `end [curly] bracket` here:

If that can help,
Regards.

commented Jun 22, 2022 by Joe
Awesome! Yeah 2022.6 fixes it for me. I tried to download that yesterday but it was a broken link until, as you mentioned, today.

The example you just sent worked fine in 2022.6. Do you want me to try that in 2022.5 as well? I think that will probably work in 2022.5 since it seemed to be something with having multiple layers of Javascript objects in the structure that confused it.
commented Jun 22, 2022 by Brad
This is a very timely answer.  Just ran across this with the 2022.05 version and also upgraded to 2022.6 and it fixed the issue.

Thanks!
...