You can build a %Library.DynamicObject or a %Library.DynamicArray (both extend the %Library.DynamicAbstractObject class) from the ResultSet and use the %ToJSON method.
To build the object it will be necessary to loop the ResultSet writing line by line.

PS: I could use the ID to get unique values, however I can only sort displayed values and I don't want to show a meaningless number (as it would be if I used the ID), so the row number would be ideal.

Try use:

##class(%Library.SQLCatalog).GetCachedQueryTableCount("table_name")

This command will return the number of Cached Queries.

So, you can check if all Cached Queries have been purged.