Over a million developers have joined DZone.

3 Common Problems Solved With JSON

· Cloud Zone

Download the Essential Cloud Buyer’s Guide to learn important factors to consider before selecting a provider as well as buying criteria to help you make the best decision for your infrastructure needs, brought to you in partnership with Internap.

common-problems-solved-with-json[This article was written by Marc Concannon.]

One of the most common questions we get asked by customers is:

“What’s the best way to log my data?”

My answer is always:

log using JSON format wherever possible.”

The next question we often get asked – (but not as much)…

Yeah JSON, …Hmmm, what is JSON again?

So JSON is: JavaScript Object Notation.

But put simply, this is a way that data can be stored in a structured format, where each piece of data will usually have an identifier (known as a key) and a value (which can be in multiple formats). It also can have a nested structure where a key can have multiple children (keys) etc. It is often referred to as a JavaScript version of XML.

The core reason for using JSON is built around the concept of KEY VALUE PAIRS (KVPs) which are ideal because they give you very precise control over the specific data you want to look for or extract and manipulate.

A simple example of JSON could be:

“car”: {
“make”: “Ford”,
“car_details”: {
“model”: “fiesta”,
“mileage”: 15000,
“color”: “yellow”,
“value”: 20000

“car”: {
“make”: “Dodge”,
“car_details”: {
“model”: “Viper”,
“mileage”: 30000,
“color”: “yellow”,
“value”: 30000

“car”: {
“make”: “Ford”,
“car_details”: {
“model”: “fiesta”,
“mileage”: 15000,
“color”: “blue”,
“value”: 20000


(Don’t forget you can send in any log data in Key Value Pairs and utilize our key highlighting and enhanced search functions.)

You can start to use the Keys to help you slice and dice the log data to your heart’s content.

So, some simple queries you could run:

How many ford cars were sold.

Where(car and make=Ford) Calculate(count)


Find the total of cars sold by make

Where(car) GroupBy(make) Calculate(sum:value)

All this is easy to do and achieve by using the simple JSON format.

As I hope you can see, by having your logs in JSON or KVP format give you a huge amount of control in how you slice and dice the data within your logs to gain the insight you want.

A real world example based on a Apache web log could be

How long is the average response time based on URI

This would be written as

Where(/.*) GroupBy(Uri) calculate(Average:Request_Time)

From which you would get a great visualisation.


But hey, the fun of working with JSON doesn’t end there…

Because you can have a hierarchal format within your log events, we can expose this parent-child relationship within the log viewport, and  make it much easier to read and visualize the log events.

We have also added a new neat little function called “Expand JSON” which, when activated, will transform your blob of JSON into its own easily readable indented structure.

See the comparison of the humble JSON log event below, before and after the “prettifying”.




You may think were finished – but wait, there’s more.

We have now also released key highlighting within your logs to make it easier for you to quickly utilize the keys. By simply clicking on keys you can quickly refine the logs selected and counted for the selected time range to only logs that contain the specific key.

It also highlights the keys that you can use for cutting and dicing the log data.


This is just our first step on a much longer road exposing new functionality around Keys and JSON which we hope will make it easier and quicker for you to navigate and gain the insight you need from your log data.

Over the next few months we will be releasing more cool functionality like, but in the meantime, if you have any feedback or suggestions on the enw Key exposure and JSON formatting we would love to hear it. Email us at suggest@logentries.com.

The Cloud Zone is brought to you in partnership with Internap. Read Bare-Metal Cloud 101 to learn about bare-metal cloud and how it has emerged as a way to complement virtualized services.


Published at DZone with permission of Trevor Parsons, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}