Groovy JSON isn’t a default part of Groovy, so you need the extra jar.
Copying it to the QuPath application won’t be enough to get it onto QuPath’s classpath. You need to drag it onto QuPath to copy it to the extensions directory to use the jar from scripts.
But you don’t need to do any of that if you use Gson to write JSON, since it’s already there as a dependency and used by QuPath to write JSON.
There’s an example showing the import here.
There have been discussions about interoperability, e.g.:
Serializing to/from JSON can be deceptively tricky and very hard to maintain in evolving software. There are a lot of design decisions to make, and relying on the default serialization from Jackson/Gson will cause problems if (/when…) the internal QuPath representation for ROIs changes. JSON serialization is also very hard to manage with interfaces and subclasses.
For that reason, I recently wrote support to serialize QuPath ROIs and objects to/from GeoJSON. The code is here but not yet in a QuPath release or tested in the real world.
Yeah, that is the problem
I try to priorities in a vaguely utilitarian way the things that will help the most people or make the biggest difference, but also keeping in mind long-term plans to improve the software more substantially and sustainable.
There’s a position currently advertised here. To help QuPath go faster, please consider either joining me or at least advertising this widely!