Member-only story

Json to Parquet in Java

Park Sehun
3 min readJun 22, 2023

Using Java to convert Json into Parquet format.

There are many solutions to convert Json to parquet in Python and you can find many code examples. In Java, there are Apache packages to help with this.

I will use net.minidev.json and org.apache.avro and org.apache.parquet libraries in the sample code.

In high-level, Json to Parquet conversion will be like

  1. Define the schema
  2. Load the JSON file and store it as GenericRecord
  3. Create the Parquet writer
  4. Write the record

Before getting into the actual code, let’s see the package groups used in the sample.

net.minidev.json vs org.json

org.json is easier to read and use. JsonObject is immutable and supports the pretty print of JsonObject and JsonArray.

import org.json.*;
public class JSONPrettyPrintTest {
public static void main(String args[]) throws JSONException {
String json = "{" +
"Name : Jai," +
"Age : 25, " +
"Salary: 25000.00 " +
"}";
JSONObject jsonObj = new JSONObject(json);
System.out.println("Pretty Print of JSON:")…

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response