highlight part in json variable

0 votes
asked Jan 20, 2023 in Question / help by kwisatz.haderach (120 points)

Hi,

Is there a way to #highlight a part of a json file loaded and shown as it follows:

@startuml

!$schema=%load_json("schema.json")

json "schema" as J $schema

@enduml

Thanks and Regards

commented Jan 20, 2023 by The-Lu (74,900 points)

Hello K. and all,

This is not [yet] possible with json object. but it is possible with JSON diagram, as:

@startjson
!$schema=%load_json("schema.json")
#highlight ...
$schema
@endjson

If that can help,
Regards.

commented Jan 23, 2023 by kwisatz.haderach (120 points)

@The-Lu ... thank you for the reply.

so, let's stick with just the JSON diagram ( for the moment :-) ).

what if I have:

@startuml

!$schema=%load_json("schema.json")

rectangle Inner #tan as "

  {{json

    $schema

  }}

  "

@enduml

Thanks again!

commented Jan 23, 2023 by The-Lu (74,900 points)

Hello K., and all,

Yes you can use this form, as:

@startuml
!$schema=%load_json("schema.json")
rectangle Inner #tan [
  {{json
    #highlight ...
    $schema
  }}
]
@enduml

Enjoy,

Regards.

commented Jan 23, 2023 by kwisatz.haderach (120 points)

it doesn't seem to like it ... hoping this link would work.

In any case it gives the "Your data does not sound like JSON data" error.

Regards

commented Jan 23, 2023 by The-Lu (74,900 points)

You are right, just change:

  • hightlight to highlight
  • and the indentation. (without any indentation)...

As:

@startuml
!$foo = { "name": "John", "age" : 30 }

rectangle Inner #tan as "
  {{json
#highlight name
    $foo
  }}
  "
@enduml

And see the expected result:

@PlantUML team: accept space before header command on JSON diagram...wink

Enjoy.

commented Jan 23, 2023 by kwisatz.haderach (120 points)

yes

btw, the mispelled #hightlight gets just ignored (no error is raised). Not sure whether is supposed to be that way.

1 Answer

0 votes
answered Feb 1, 2023 by The-Lu (74,900 points)

[In order to put my answer on an answer area]

Here is a possible answer:

@startuml
!$foo = { "name": "John", "age" : 30 }

rectangle Inner #tan as "
  {{json
#highlight name
    $foo
  }}
  "
@enduml

And see the expected result:

@PlantUML team: accept space before header command on JSON diagram...wink

Enjoy.


Regards.

...