Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: EntriesModel parsing fix #149

Merged
merged 5 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# CHANGELOG

## v2.0.2

### Date: 5-December-2024

-Github Issue fixed
-EntriesModel parsing fix

## v2.0.1

### Date: 21-October-2024
Expand Down
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.contentstack.sdk</groupId>
<artifactId>java</artifactId>
<version>2.0.1</version>
<version>2.0.2</version>
<packaging>jar</packaging>
<name>contentstack-java</name>
<description>Java SDK for Contentstack Content Delivery API</description>
Expand All @@ -20,11 +20,11 @@
<maven-source-plugin.version>3.3.1</maven-source-plugin.version>
<maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
<dotenv-source.version>3.0.0</dotenv-source.version>
<rxjava-source.version>3.1.8</rxjava-source.version>
<rxjava-source.version>3.1.9</rxjava-source.version>
<retrofit-source.version>2.11.0</retrofit-source.version>
<loggin.version>5.0.0-alpha.11</loggin.version>
<jococo-plugin.version>0.8.5</jococo-plugin.version>
<lombok-source.version>1.18.32</lombok-source.version>
<lombok-source.version>1.18.34</lombok-source.version>
<junit-jupiter.version>5.10.1</junit-jupiter.version>
<junit-jupiter-engine.version>5.8.0-M1</junit-jupiter-engine.version>
<gson.version>2.8.8</gson.version>
Expand Down Expand Up @@ -187,7 +187,7 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
<version>2.18.0</version>
</dependency>
</dependencies>

Expand Down
15 changes: 8 additions & 7 deletions src/main/java/com/contentstack/sdk/EntriesModel.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.contentstack.sdk;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
Expand All @@ -18,13 +18,14 @@ protected EntriesModel(JSONObject responseJSON) {
this.jsonObject = responseJSON;
objectList = new ArrayList<>();
Object entryList = jsonObject.opt("entries");
if (entryList instanceof JSONArray) {
JSONArray entries = (JSONArray) entryList;
if (entries.length() > 0) {
if (entryList instanceof ArrayList) {
ArrayList<LinkedHashMap> entries = (ArrayList) entryList;
if (!entries.isEmpty()) {
entries.forEach(model -> {
if (model instanceof JSONObject) {
JSONObject newModel = (JSONObject) model;
EntryModel entry = new EntryModel(newModel);
if (model instanceof LinkedHashMap) {
// Convert LinkedHashMap to JSONObject
JSONObject jsonModel = new JSONObject((LinkedHashMap<?, ?>) model);
EntryModel entry = new EntryModel(jsonModel);
objectList.add(entry);
}
});
Expand Down
Loading