Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Syntax error on two and more array items in macros #1477

Closed
MOZGIII opened this issue Jul 12, 2023 · 2 comments · Fixed by #1613
Closed

Syntax error on two and more array items in macros #1477

MOZGIII opened this issue Jul 12, 2023 · 2 comments · Fixed by #1613
Labels

Comments

@MOZGIII
Copy link
Collaborator

MOZGIII commented Jul 12, 2023

Describe the bug

Works:

!$myarray=["a"]

Broken:

!$myarray=["a","b"]

To Reproduce

Create a file with the contents above, and render it.

Expected behavior

No error, array is defined and available for use (i.e. looping over).

Screenshots

Desktop (please complete the following information):

  • OS: macOS
  • Browser: -
  • Version: versions from 2022 till 2023 (including latest release)

Smartphone (please complete the following information):

No

Additional context
Add any other context about the problem here.

@The-Lum
Copy link
Collaborator

The-Lum commented Sep 5, 2023

Hello @MOZGIII, and all,

According your constat:

Works:

!$myarray=["a"]

Broken:

!$myarray=["a","b"]

@MOZGIII:

  1. How to the first works?
  2. Could you give an example?

Because currently only 3 kinds of type are available on PlantUML:

There are three types of data:

  • Integer number(int);
  • String(str) - these must be surrounded by single quote or double quote;
  • JSON(JSON) - these must be surrounded by curly brackets.

See also doc. here:


Then here is a workaround, in order to manage array items, using JSON type, as:

@startuml
!$myarray={"key": ["a","b"]}
legend
test of JSON array:
myarray.key[0] = $myarray.key[0]
myarray.key[1] = $myarray.key[1]
endlegend
@enduml

Enjoy,
Regards,
Th.

@MOZGIII
Copy link
Collaborator Author

MOZGIII commented Sep 5, 2023

I see! The workaround is unexpected, because all these are valid JSON values: "qwe", 123, [], {}, meaning only JSON objects (the { ... } kinds of values) are supported. This could be documented better.

I have no idea how come that ["a"] works if the JSON arrays are not supported. I just thought they were supported but the support was bugged.

Anyhow, thanks for the workaround. It is ugly to write, but if I can put it inside of a macro call (i.e. do something like array([ .. ]) to produce the { "dummy": [...] } under the hood that would be good enough). It would be better to support JSON arrays though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants