loadJSON function

+4 votes
asked May 2, 2020 in Wanted features by Seb

When do you plan to integrate loadJSON function as it is proposed in the wiki ?



1 Answer

+1 vote
answered Nov 10, 2021 by Aljoscha Rittner

Good morning!

I implemented a loadJSON function yesterday and wanted to make a pull request shortly. The implementation uses SFile and SURL so that JSON data can be loaded locally and from REST interfaces. I followed the proposal on the http://wiki.plantuml.net/site/preprocessing-json site. However, there are two more optional parameters. A default JSON if the data source does not provide any data and the possibility to define a charset encoding.

Here is an example:


' This example works only with the latest plantuml snapshot an implemented
' %loadJSON function

' Default JSON, if we don't get a content from the data source
!$DEF={"status": "not connected"}

' Load from Spring boot service with actuator 'health' endpoint
!$TEST=%loadJSON("http://localhost:7778/management/health", $DEF)

' Load from local file (relative located in plantuml.include.path list)

title Load JSON example with $DEMO.status

' Simple usage
[Service] -> ($TEST.status): is

' Embedded rendering of JSON structure
 rectangle Inner #tan as "
    Health of management service at %date()


commented Nov 10, 2021 by plantuml (277,100 points)
That's great!

We are looking forward to reviewing your pull request and we will merge it if there is no security issue there.

commented Nov 10, 2021 by Aljoscha Rittner

I created a PR: https://github.com/plantuml/plantuml/pull/755

Any comments and ideas to improve it are very welcome. :-)

best regards, Aljoscha