Home » JSON

Tag Archives: JSON

Command-line JSON processing with jq

In this post we will learn how to parse, pretty-print and process JSON from the command-line with jq. At the end we will even use jq to do a simple JSON to CSV conversion. jq describes itself as a lightweight and flexible command-line JSON processor. You can think of unix shell tools like sed, grep and awk but for JSON. ...

Read More »

Integrating JSON Schema validation in Spring using a custom HandlerMethodArgumentResolver

In previous posts we learned about JSON Schema and how we can validate a JSON document against a JSON Schema in Java. In this post we will integrate JSON Schema validation into Spring controllers using a custom HandlerMethodArgumentResolver. We will use the same JSON document and JSON Schema as in previous posts. So, what is a HandlerMethodArgumentResolver? Handler methods in ...

Read More »

JSON Schema validation in Java

In this post we will see how to validate a JSON document against a JSON Schema in Java. We will use the same JSON document and Schema as in the previous post about JSON Schema. You can find both as text files on GitHub: JSON document and JSON Schema. We use the networknt JSON Schema validator library in this example. ...

Read More »

Validating and documenting JSON with JSON Schema

JSON Schema is a way to describe a JSON document. You can think of XML Schema for JSON. It allows you to define required elements, provide validation constraints and documentation. I think the easiest way to explain JSON Schema is to look at an example snippet of JSON and the corresponding JSON Schema. So, I created an image that shows ...

Read More »

Data encoding and storage

Data encoding and storage formats are evolving fields. It has seen so many changes starting from naive text-based encoding to advance compact nested binary format. Selecting correct encoding/storage format has big impact on application performance and how easily it can evolve. Data encoding has big impact on whether application is backward/forward compatible. Selecting right encoding format can be one of ...

Read More »

Escape JSON property names in jq

I’m using the command line a lot and jq is a helpful tool for dealing with JSON data. You can access JSON object properties and array elements by concatenating the property names with dots and square brackets: 1 gt; cat ~/.docker/config.json { "auths": { "https://index.docker.io/v1/": { "auth": "aBcDeFghiJKlMn=" }, [...] } } 1 gt; cat .docker/config.json | jq . { ...

Read More »

In praise of the thoughful design: how property-based testing helps me to be a better developer

The developer’s testing toolbox is one of these things which rarely stays unchanged. For sure, some testing practices have proven to be more valuable than others but still, we are constantly looking for better, faster and more expressive ways to test our code. Property-based testing, largely unknown to Java community, is yet another gem crafted by Haskell folks and described ...

Read More »

Hash a Json

I recently wrote a simple library to predictably hash a json. The utility is built on top of the excellent Jackson Json parsing library Problem I needed a hash generated out of a fairly large json based content to later determine if the content has changed at all. Treating json as a string is not an option as formatting, shuffling ...

Read More »