Export json data of selected objects

Hello!
I’d like to export json data of selected parts only.
How can I do this?
Model.toJson() exports whole diagram.
But I’d like to export only selected parts.
Best

It is probably easiest to create a temporary unseen Diagram, call Diagram.copyParts of the main Diagram.selection to the temporary diagram, and then call Model.toJson on the temporary diagram’s model.