Skip to content

Commit 8187fba

Browse files
committed
Remove org.json lib fork and use new version of the API https://github.com/stleary/JSON-java
Issue: 105607
1 parent 30fdb7f commit 8187fba

File tree

4 files changed

+36
-11
lines changed

4 files changed

+36
-11
lines changed

common/src/main/java/com/genexus/GXSimpleCollection.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
import com.genexus.internet.IGxJSONAble;
1717
import com.genexus.internet.IGxJSONSerializable;
1818
import com.genexus.internet.StringCollection;
19+
import com.genexus.json.JSONArrayWrapper;
1920
import com.genexus.util.GXMap;
2021
import com.genexus.util.Quicksort;
2122
import com.genexus.xml.XMLReader;
22-
2323
import com.genexus.xml.XMLWriter;
2424

2525
import org.json.JSONArray;
@@ -33,7 +33,7 @@ public class GXSimpleCollection<T> extends GXBaseList<T> {
3333
protected String xmlElementsName;
3434
protected String containedXmlNamespace = "";
3535
protected int remoteHandle = -1;
36-
protected JSONArray jsonArr = new JSONArray();
36+
protected JSONArrayWrapper jsonArr = new JSONArrayWrapper();
3737

3838
public GXSimpleCollection()
3939
{
@@ -979,7 +979,7 @@ public void tojson()
979979
}
980980
public void tojson(boolean includeState)
981981
{
982-
jsonArr = new JSONArray();
982+
jsonArr = new JSONArrayWrapper();
983983
int size = size();
984984
for (int i = 0; i < size; i++)
985985
{
@@ -1118,7 +1118,7 @@ public boolean fromJSonString(String s, GXBaseCollection<SdtMessages_Message> me
11181118
{
11191119
try
11201120
{
1121-
jsonArr = new JSONArray(s);
1121+
jsonArr = new JSONArrayWrapper(s);
11221122
FromJSONObject(jsonArr);
11231123
return true;
11241124
}
@@ -1144,7 +1144,7 @@ public void fromStringCollectionJsonString(String s)
11441144
this.clear();
11451145
try
11461146
{
1147-
jsonArr = new JSONArray(s);
1147+
jsonArr = new JSONArrayWrapper(s);
11481148
for (int i = 0; i < jsonArr.length(); i++)
11491149
{
11501150
JSONArray jsonObj = jsonArr.getJSONArray(i);
@@ -1224,7 +1224,7 @@ public void fromStringCollectionClientJsonString(String s)
12241224
{
12251225
this.clear();
12261226
try {
1227-
jsonArr = new JSONArray(s);
1227+
jsonArr = new JSONArrayWrapper(s);
12281228
} catch (JSONException e) {
12291229
// TODO Auto-generated catch block
12301230
e.printStackTrace();
@@ -1291,7 +1291,7 @@ private boolean processArray(GxUnknownObjectCollection oldParent, GxUnknownObjec
12911291

12921292
public JSONArray getRawJSONArray()
12931293
{
1294-
return jsonArr;
1294+
return (JSONArray)jsonArr;
12951295
}
12961296

12971297
// toString of GxUnknownObjectCollection as client proc expect, table info + rows.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.genexus.json;
2+
3+
import org.json.JSONArray;
4+
5+
import java.util.LinkedHashMap;
6+
7+
public class JSONArrayWrapper extends JSONArray implements java.io.Serializable{
8+
9+
public JSONArrayWrapper() {
10+
super();
11+
}
12+
13+
public JSONArrayWrapper(String string) {
14+
super(string);
15+
}
16+
17+
public JSONArrayWrapper(JSONArray array) {
18+
super(array);
19+
}
20+
}

common/src/main/java/com/genexus/json/JSONObjectWrapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import java.util.Map.Entry;
66
import org.json.JSONException;
77
import org.json.JSONObject;
8-
public class JSONObjectWrapper extends JSONObject{
8+
public class JSONObjectWrapper extends JSONObject implements java.io.Serializable{
99
private Map<String, Object> map;
1010

1111
public JSONObjectWrapper() {

common/src/main/java/com/genexus/xml/GXXMLSerializable.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
import com.genexus.common.classes.AbstractGXFile;
44
import com.genexus.ModelContext;
55
import com.genexus.common.interfaces.SpecificImplementation;
6+
import com.genexus.json.JSONArrayWrapper;
7+
import com.genexus.json.JSONObjectWrapper;
68
import com.genexus.util.GXProperties;
79

810
import org.json.JSONArray;
911
import org.json.JSONException;
1012
import org.json.JSONObject;
11-
import com.genexus.json.JSONObjectWrapper;
1213

1314
import java.io.Serializable;
1415
import java.util.Iterator;
@@ -40,7 +41,7 @@ public GXXMLSerializable(int remoteHandle, ModelContext context, String type)
4041
private static final String GET_METHOD_NAME = "getgxTv_";
4142
private static final String SET_METHOD_NAME = "setgxTv_";
4243
private JSONObjectWrapper jsonObj = new JSONObjectWrapper();
43-
private JSONArray jsonArr = new JSONArray();
44+
private JSONArrayWrapper jsonArr = new JSONArrayWrapper();
4445
protected boolean isArrayObject = false;
4546
protected String arrayItemName;
4647
protected String type;
@@ -240,7 +241,11 @@ public void AddObjectProperty(String name, Object prop, boolean includeState, bo
240241
}
241242
else if (isArrayObject)
242243
{
243-
jsonArr = (JSONArray)((IGxJSONAble)prop).GetJSONObject(includeState);
244+
Object obj = ((IGxJSONAble)prop).GetJSONObject(includeState);
245+
if (obj instanceof JSONArrayWrapper)
246+
jsonArr = (JSONArrayWrapper)obj;
247+
else
248+
jsonArr = new JSONArrayWrapper((JSONArray)obj);
244249
}
245250
else
246251
{

0 commit comments

Comments
 (0)