Get "%p" to print legal json or convert "%p" to json

SystemVerilog %p prints something that looks like json but is not actually json. Wonder if anybody tried to get json out of it or has a script they can share.
Also, is this coming up in next standard (i.e. %p prints json)?

In reply to avidan_apple:

Hi Avidan,

Dumping JSON would be fairly straightforward using a combination of the SystemVerilog VPI and a C json library. Parsing json and building a data structure that represents it is much more complicated.

I have not seen a request for this before. Usually people want to dump a large amounts of data from a simulation and json is not very efficient. It does not handle 4-state values or bit widths/ranges, so you might have to dump all values as a string.

The %p format is for dumping values as a SystemVerilog assignment pattern. We cannot change this and would have to add something else to the language to make this happen.

In reply to dave_59:

Hi Dave,

Thanks for answering on your Christmas break, and happy new year!

You’re right, it would likely not be very efficient, and that json would make a lot of our data just strings. But in this case I’m just looking to prototyping some quick checkers in python based on logs, and the performance doesn’t matter much as we’re talking big cluster level where we have 99 problems before we’ll see the impact of %p.

So, this could come in handy…I’ll just stop being lazy and write it :-)