Skip to content

Commit 148fd23

Browse files
Vikram KaltaVikram Kalta
authored andcommitted
fix: EntriesModel parsing fix
1 parent 2a561bf commit 148fd23

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66
<groupId>com.contentstack.sdk</groupId>
77
<artifactId>java</artifactId>
8-
<version>2.0.1</version>
8+
<version>2.0.2</version>
99
<packaging>jar</packaging>
1010
<name>contentstack-java</name>
1111
<description>Java SDK for Contentstack Content Delivery API</description>

src/main/java/com/contentstack/sdk/EntriesModel.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.contentstack.sdk;
22

3-
import org.json.JSONArray;
43
import org.json.JSONObject;
54

65
import java.util.ArrayList;
6+
import java.util.LinkedHashMap;
77
import java.util.List;
88
import java.util.logging.Level;
99
import java.util.logging.Logger;
@@ -18,13 +18,14 @@ protected EntriesModel(JSONObject responseJSON) {
1818
this.jsonObject = responseJSON;
1919
objectList = new ArrayList<>();
2020
Object entryList = jsonObject.opt("entries");
21-
if (entryList instanceof JSONArray) {
22-
JSONArray entries = (JSONArray) entryList;
23-
if (entries.length() > 0) {
21+
if (entryList instanceof ArrayList) {
22+
ArrayList<LinkedHashMap> entries = (ArrayList) entryList;
23+
if (!entries.isEmpty()) {
2424
entries.forEach(model -> {
25-
if (model instanceof JSONObject) {
26-
JSONObject newModel = (JSONObject) model;
27-
EntryModel entry = new EntryModel(newModel);
25+
if (model instanceof LinkedHashMap) {
26+
// Convert LinkedHashMap to JSONObject
27+
JSONObject jsonModel = new JSONObject((LinkedHashMap<?, ?>) model);
28+
EntryModel entry = new EntryModel(jsonModel);
2829
objectList.add(entry);
2930
}
3031
});

0 commit comments

Comments
 (0)