com.contentstack.sdk.GlobalFieldsModel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of java Show documentation
Show all versions of java Show documentation
Java SDK for Contentstack Content Delivery API
The newest version!
package com.contentstack.sdk;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
/**
* The GlobalFieldsModel that contains global fields response
*/
public class GlobalFieldsModel {
private Object response;
private JSONArray responseJSONArray = new JSONArray();
public void setJSON(JSONObject responseJSON) {
if (responseJSON != null) {
String gfKey = "global_field";
if (responseJSON.has(gfKey) && responseJSON.opt(gfKey) instanceof LinkedHashMap) {
try {
this.response = new JSONObject((LinkedHashMap, ?>) responseJSON.get(gfKey));
} catch (Exception e) {
System.err.println("Error processing 'global_field': " + e.getMessage());
}
}
String gfListKey = "global_fields";
if (responseJSON.has(gfListKey) && responseJSON.opt(gfListKey) instanceof ArrayList) {
try {
ArrayList> globalFields = (ArrayList) responseJSON.get(gfListKey);
List © 2015 - 2025 Weber Informatics LLC | Privacy Policy