dont' know if this will help, but I parse json using this:

 List<Map<String, String>> DataStruct = new ArrayList<Map<String, String>>();

JSONObject jSONObject = new JSONObject(Result);             
                    JSONArray entriesArr = jSONObject.getJSONArray("entries");
                    ItemsThisPage = entriesArr.length();
                      for (int i=0; i<ItemsThisPage; i++)
                      {
                          // FOR EACH ENTRY
                          JSONObject OneEntry = entriesArr.getJSONObject(i);
                          int OneEntrySize = OneEntry.length();
                          JSONArray EntKey = OneEntry.names(); 
                           Map<String, String> JsonItem = new HashMap<String, String>();
                          for (int j=0; j<OneEntrySize;j++)
                          {   // FOR EACH ITEM IN AN ENTRY
                              EntVal = EntKey.getString(j);
                              GenCell = OneEntry.opt(EntVal).toString();
                              JsonItem.put(EntVal, GenCell);            
                          }                       
                          DataStruct.add(JsonItem);                 
                      }    // end page loop     

into a 2d array, where the property name is the key, and the value the value (if that makes sense). then I access any given thing with

Itemname = DataStruct.get(Record_Number).get("Json Key here");

I have a separate routine for working out the record number, but that's just a loop with pattern matching agains a given value in the start of the Json entry.

Answer from Louise on Stack Overflow
🌐
Mkyong
mkyong.com › home › java › how to parse json array with jackson
How to parse JSON Array with Jackson - Mkyong.com
April 23, 2024 - convert JSON array to List List<Person> person2 = mapper.readValue(jsonArray, new TypeReference<>() { }); person2.forEach(System.out::println); } } output · Person{name='mkyong', age=42} Person{name='ah pig', age=20} Person{name='mkyong', age=42} Person{name='ah pig', age=20} JsonArrayToObjectExample2.java ·
Top answer
1 of 7
2

dont' know if this will help, but I parse json using this:

 List<Map<String, String>> DataStruct = new ArrayList<Map<String, String>>();

JSONObject jSONObject = new JSONObject(Result);             
                    JSONArray entriesArr = jSONObject.getJSONArray("entries");
                    ItemsThisPage = entriesArr.length();
                      for (int i=0; i<ItemsThisPage; i++)
                      {
                          // FOR EACH ENTRY
                          JSONObject OneEntry = entriesArr.getJSONObject(i);
                          int OneEntrySize = OneEntry.length();
                          JSONArray EntKey = OneEntry.names(); 
                           Map<String, String> JsonItem = new HashMap<String, String>();
                          for (int j=0; j<OneEntrySize;j++)
                          {   // FOR EACH ITEM IN AN ENTRY
                              EntVal = EntKey.getString(j);
                              GenCell = OneEntry.opt(EntVal).toString();
                              JsonItem.put(EntVal, GenCell);            
                          }                       
                          DataStruct.add(JsonItem);                 
                      }    // end page loop     

into a 2d array, where the property name is the key, and the value the value (if that makes sense). then I access any given thing with

Itemname = DataStruct.get(Record_Number).get("Json Key here");

I have a separate routine for working out the record number, but that's just a loop with pattern matching agains a given value in the start of the Json entry.

2 of 7
2

You can read the file data into a String and than that string can be converted into Java Hashmap by using Jackson lib. You can use ObjectMapper class for that. Here is sample code for how to do it :

ObjectMapper objectMapper = new ObjectMapper();
HashMap<String, String> tempMap = objectMapper.readValue(jsonString,
            new TypeReference<HashMap<String, String>>() {
            });

Here in the above code jsonString is the String containing the JSON data. Hope that solves your problem.

🌐
TutorialsPoint
tutorialspoint.com › how-can-we-convert-a-json-array-to-a-list-using-jackson-in-java
How can we convert a JSON array to a list using Jackson in Java?\\n
June 5, 2025 - import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.List; import java.io.IOException; import java.util.ArrayList; public class JsonArrayToList{ public static void main(String[] args) { String jsonArray = "[{"name":"John","age":30},{"name":"Jane","age":25}]"; ObjectMapper objectMapper = new ObjectMapper(); try { List<Person> personList = objectMapper.readValue(jsonArray, new TypeReference<List<Person>>(){}); for (Person person : personList) { System.out.println("Name: " + person.getName() + ", Age: " + person.getAge()); } }
🌐
Baeldung
baeldung.com › home › json › jackson › convert json array to java list
Convert JSON Array to Java List | Baeldung
August 13, 2025 - Then, we use the readValue() method of the ObjectMapper object to convert the JSON array String to a List. Similar to the assertion discussed previously, finally, we compare a specific field from the String JSON array to the jacksonList ...
🌐
Codez Up
codezup.com › home › best way to convert json to map in java
Best Way to Convert JSON to Map in Java | Codez Up
February 2, 2024 - Below is the conversion of such type of JSONArray to the List and then map: ... package com.jsonarraytomap; import java.util.Arrays; import java.util.List; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; public class JsonArrayToMap { public static void main(String[] args) throws JsonMappingException, JsonProcessingException { ObjectMapper objectMapper = new ObjectMapper(); String json = "[{\r\n" + " \"age\": 24,\r\n" + " \"name\": \"Robert\"\r\n" + "}, {\r\n" + " \"age\":
🌐
GitHub
gist.github.com › 4201429
Convert Android JSONObject/JSONArray to a standard Map/List. · GitHub
Convert Android JSONObject/JSONArray to a standard Map/List. - JsonHelper.java
🌐
Attacomsian
attacomsian.com › blog › jackson-convert-json-array-to-from-java-list
Convert JSON array to a list using Jackson in Java
November 6, 2022 - The following example demonstrates how to use the writeValueAsString() method from the ObjectMapper class to convert a list of Java Objects to their JSON array representation:
Find elsewhere
Top answer
1 of 1
1

You can read whole JSON payload as JsonNode and retrieve data property which is an array. If we can assume that always first element is array of names and all other elements are equal in size you can create Map manually and serialise it back to JSON. One tricky part is how to generate unique key value for the result JSON. Example code could look like below:

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.node.ArrayNode;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class Excel2JonsApp {
    public static void main(String[] args) throws IOException {
        File jsonFile = new File("./resource/test.json").getAbsoluteFile();

        Excel2JsonMapper mapper = new Excel2JsonMapper();
        String json = mapper.convertToJson(jsonFile);
        System.out.println(json);
    }
}

class Excel2JsonMapper {
    private final ObjectMapper jsonMapper;

    Excel2JsonMapper() {
        this.jsonMapper = createJsonMapper();
    }

    private ObjectMapper createJsonMapper() {
        ObjectMapper mapper = new ObjectMapper();
        mapper.enable(SerializationFeature.INDENT_OUTPUT);

        return mapper;
    }

    String convertToJson(File jsonFile) throws IOException {
        ArrayNode arrayNode = readDataArray(jsonFile);
        Map<Object, Map<String, JsonNode>> dataMap = convertArrayToMaps(arrayNode)
                .stream()
                .collect(Collectors.toMap(
                        map -> map.get("PARENT ITEM NUMBER").textValue(), //key generator function
                        Function.identity()));

        return jsonMapper.writeValueAsString(Collections.singletonMap("data", dataMap));
    }

    private List<Map<String, JsonNode>> convertArrayToMaps(ArrayNode arrayNode) {
        ArrayNode names = (ArrayNode) arrayNode.get(0);

        Iterator<JsonNode> iterator = arrayNode.iterator();
        iterator.next();// skip names

        List<Map<String, JsonNode>> list = new ArrayList<>();
        while (iterator.hasNext()) {
            ArrayNode values = (ArrayNode) iterator.next();
            Map<String, JsonNode> map = new LinkedHashMap<>();
            for (int i = 0; i < names.size(); i++) {
                map.put(names.get(i).textValue(), values.get(i));
            }
            list.add(map);
        }
        return list;
    }

    private ArrayNode readDataArray(File jsonFile) throws IOException {
        JsonNode root = jsonMapper.readTree(jsonFile);
        return (ArrayNode) root.at("/sheets/0/data");
    }
}

Above code prints:

{
  "data" : {
    "208E8840168" : {
      "BRANCH" : "B20",
      "PARENT ITEM NUMBER" : "208E8840168",
      "2ND ITEM NUMBER" : "5P884LPFSR2",
      "QUANTITY REQUIRED" : 1.36,
      "UNIT OF MEASURE" : "LB",
      "ISSUE TYPE CODE" : "I",
      "LINE TYPE" : "S",
      "STOCK TYPE" : "M",
      "TYPE BOM" : "M",
      "LINE NUMBER" : 1.0,
      "OPERATING SEQUENCE" : 10.0,
      "EFFECTIVE FROM DATE" : "02/26/08",
      "EFFECTIVE THRU DATE" : "12/31/40",
      "DRAWING NUMBER" : null,
      "UNIT COST" : 0.0,
      "SCRAP PERCENT" : 0.0
    },
    "21PPH150166" : {
      "BRANCH" : "B20",
      "PARENT ITEM NUMBER" : "21PPH150166",
      "2ND ITEM NUMBER" : "8P315TPMRG",
      "QUANTITY REQUIRED" : 1.39629,
      "UNIT OF MEASURE" : "LB",
      "ISSUE TYPE CODE" : "I",
      "LINE TYPE" : "S",
      "STOCK TYPE" : "M",
      "TYPE BOM" : "M",
      "LINE NUMBER" : 1.0,
      "OPERATING SEQUENCE" : 10.0,
      "EFFECTIVE FROM DATE" : "03/05/18",
      "EFFECTIVE THRU DATE" : "12/31/40",
      "DRAWING NUMBER" : null,
      "UNIT COST" : 0.0,
      "SCRAP PERCENT" : 0.0
    },
    "208E8840180" : {
      "BRANCH" : "B20",
      "PARENT ITEM NUMBER" : "208E8840180",
      "2ND ITEM NUMBER" : "5P884LPFSR2",
      "QUANTITY REQUIRED" : 1.4565,
      "UNIT OF MEASURE" : "LB",
      "ISSUE TYPE CODE" : "I",
      "LINE TYPE" : "S",
      "STOCK TYPE" : "P",
      "TYPE BOM" : "M",
      "LINE NUMBER" : 1.0,
      "OPERATING SEQUENCE" : 10.0,
      "EFFECTIVE FROM DATE" : "03/04/09",
      "EFFECTIVE THRU DATE" : "12/31/40",
      "DRAWING NUMBER" : null,
      "UNIT COST" : 0.0,
      "SCRAP PERCENT" : 0.0
    },
    "208E8840172" : {
      "BRANCH" : "B20",
      "PARENT ITEM NUMBER" : "208E8840172",
      "2ND ITEM NUMBER" : "5P884LPFSR2",
      "QUANTITY REQUIRED" : 1.3924,
      "UNIT OF MEASURE" : "LB",
      "ISSUE TYPE CODE" : "I",
      "LINE TYPE" : "S",
      "STOCK TYPE" : "M",
      "TYPE BOM" : "M",
      "LINE NUMBER" : 1.0,
      "OPERATING SEQUENCE" : 10.0,
      "EFFECTIVE FROM DATE" : "02/26/08",
      "EFFECTIVE THRU DATE" : "12/31/40",
      "DRAWING NUMBER" : null,
      "UNIT COST" : 0.0,
      "SCRAP PERCENT" : 0.0
    },
    "208E8840040" : {
      "BRANCH" : "B20",
      "PARENT ITEM NUMBER" : "208E8840040",
      "2ND ITEM NUMBER" : "5P884LPFSR2",
      "QUANTITY REQUIRED" : 0.32031,
      "UNIT OF MEASURE" : "LB",
      "ISSUE TYPE CODE" : "I",
      "LINE TYPE" : "S",
      "STOCK TYPE" : "M",
      "TYPE BOM" : "M",
      "LINE NUMBER" : 1.0,
      "OPERATING SEQUENCE" : 10.0,
      "EFFECTIVE FROM DATE" : "09/11/13",
      "EFFECTIVE THRU DATE" : "12/31/40",
      "DRAWING NUMBER" : null,
      "UNIT COST" : 0.0,
      "SCRAP PERCENT" : 0.0
    }
  }
}
🌐
Stack Abuse
stackabuse.com › converting-json-array-to-a-java-array-or-list
Convert JSON Array to a Java Array or List with Jackson
September 8, 2020 - Created by Guido van Rossum and first released in 1991.'} Language{name='JS', description='JS is a programming language that conforms to the ECMAScript specification. JavaScript is high-level, often just-in-time compiled, and multi-paradigm.'} In this article, we've used Jackson to parse and map the values from a JSON String and file into a Java array and list.
🌐
How to do in Java
howtodoinjava.com › home › convert json array to list: gson, jackson and org.json
Convert JSON Array to List: Gson, Jackson and Org.json
September 25, 2023 - Learn to use Gson, Jackson, and Org.json libraries to convert a JSON array into an ArrayList of objects with easy-to-understand examples.
🌐
Stack Overflow
stackoverflow.com › questions › 72828350 › convert-json-to-mapstring-listobject-in-java
Convert JSON to Map<String, List<Object>> in java
March 16, 2023 - Can someone help me in achieving this. ... ObjectMapper mapper = new ObjectMapper(); Map<String, ArrayList<Type>> map = mapper.readValue(msg,new TypeReference<HashMap<String, ArrayList<Type>>>(){});
Top answer
1 of 2
3

You can use Jackson ObjectMapper with TypeReference , First you need to read it as Map<String,Object> then you can extract the name and num with Java.

you need to get the data from obj then for each item in the dataList you have to map it to a new HashMap as shown below

ObjectMapper objectMapper = new ObjectMapper ();
Map<String,Object> jsonMap = objectMapper.readValue(jsonData,new TypeReference<Map<String,Object>>(){});
List<Object> data = ((Map<String,Object>)jsonMap.get("obj")).get("data");
List<Map<String,String> result = data.stream()
   .map(d->(Map<String,Object> d)
   .map(d->{
      Map<String,String> map = new HashMap();
      map.put(d.get("name"),((Map<String,String>)d.get("value")).get("num"));
      return map;
      })
   .collect(Collectors.toList());

However if you can create a class for the the data it will be bit easier.

2 of 2
1

Library Josson can do the job.

https://github.com/octomix/josson

Deserialization

Josson josson = Josson.fromJsonString(
    "{" +
    "  \"code\": 1," +
    "  \"msg\": \"query success\"," +
    "  \"obj\": {" +
    "    \"data\": [" +
    "      {" +
    "        \"name\": \"\"," +
    "        \"value\": {" +
    "          \"num\": \"89\"" +
    "        }" +
    "      }," +
    "      {" +
    "        \"name\": \"1\"," +
    "        \"value\": {" +
    "          \"num\": \"19\"" +
    "        }" +
    "      }," +
    "      {" +
    "        \"name\": \"2\"," +
    "        \"value\": {" +
    "          \"num\": \"6\"" +
    "        }" +
    "      }" +
    "    ]" +
    "  }," +
    "  \"success\": true," +
    "  \"duration\": 523" +
    "}");

Transformation

JsonNode node = josson.getNode("obj.data.map(name::value.num)");
System.out.println(node);

List<Map<String, String>> result = Josson.readValueFor(node, List.class);
System.out.println(result);

Output

[{"":"89"},{"1":"19"},{"2":"6"}]

[{=89}, {1=19}, {2=6}]
🌐
HowToDoInJava
howtodoinjava.com › home › gson › gson – parse json array to java array or list
Gson - Parse JSON Array to Java Array or List
January 11, 2023 - We can use the fromJson() method in the usual manner and it will parse the JSON array correctly to the required java array or list.
🌐
BeginnersBook -
beginnersbook.com › home › java › convert json array to arraylist in java
Convert JSON Array to ArrayList in Java
June 13, 2024 - If you want the ArrayList of custom objects as output then you need to create a custom class to map the JSON object. In previous example, the JSON array contain the person name and age data. Let’s create a custom class Person with name and age as instance variables to map JSON object. import ...