Bill Roper (billroper) wrote,
Bill Roper
billroper

The More You Know: JSON Edition

Having been tasked to generate some JSON in Java, I went out looking for tools, because I hate dealing with the trivia of punctuation. :)

I found the JsonWriter which generated correctly formed JSON.

Slowly. Very slowly. As in, it took about seven seconds to format 18,000 cells of data based on my rough count as it ran in the JDev debugger.

Not surprisingly, folks were not exactly thrilled with that report.

So I did some more research today. It turns out that JsonWriter constructs a JSON structure in memory, much like DOM does for XML. If you've got an itty-bitty structure, this is just fine. If you have large structures, not so much.

Happily, there is a streaming JSON API via the JsonGenerator interface. It plunked out the same 750K of data in less than a second. The limiting factor no longer appears to be the speed with which I can generate the JSON, but rather the speed with which I can retrieve the data and convert it from numeric to string format.

I like streaming APIs...
Tags: computers, java, musings, tech, work
Subscribe

  • Time for Rebuilding

    Well, there's nothing like research. Having determined that DDR5 is going to carry a substantial price premium over DDR4 memory for at least a year…

  • Driven Wild

    The studio computer continues to misbehave in various ways. When I fired up Cubase today, I got a lot of nasty, blocky video, despite having cleaned…

  • Some Old Doggerel

    I recall having mangled a CSN tune many years ago on the way to Contraption. Like that convention, the particular co-worker whose code I was digging…

  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 1 comment