How to load local json data from a file ?

0 votes
asked Jun 20, 2023 in Question / help by Ivan

Hey All,

Quick question regarding json data loading.

I'm working with PlantUML VSCode extension(I'haven't modified any setting except PlantUML server configuration in VSCode so it will use PlantUML Server docker to render my diagrams.

I reviewed the documentation regarding JSON pre-processing.

And tried to load some json data into my existing puml file.

@startuml testing-json-load-data

title Testing Json Preprocessing

!$foo= %load_json(data.json)

!$bar = {"name": "ALICE"}

participant alice as "Alice"

participant bob as "Bob"

alice ->> bob ++: "Hello!"

bob -->> alice --: "Hey Alice! $"

alice -> bob : "$foo"


I'm not able to view the contents of the data.json file, which is:

{"name": "Alice, "age": 42} instead I'm getting an empty object.

The json file itself is placed on the same directory with my-test.puml file.

My question is simple: what am I doing wrong? What are the things that I can check to resolve this issue?

Sorry if it's a newbie question, I wasn't able to find any good documentation on this.

Thanks a lot in advance.

1 Answer

0 votes
answered Jun 27, 2023 by anonymous

So I'm replying to myself and  folks who will come after)

For now the problem was resolved by doing some additional RTFM here :

And switching to the "Local" under PlantUML server settings in VSCode.

It works, but the drawback is slower rendering.

If there's someone who can point for additional options for me to explore please drop a line.