diff --git a/src/main/java/org/json/JSONArray.java b/src/main/java/org/json/JSONArray.java index 2a8a1d209..7239eefbf 100644 --- a/src/main/java/org/json/JSONArray.java +++ b/src/main/java/org/json/JSONArray.java @@ -25,6 +25,7 @@ of this software and associated documentation files (the "Software"), to deal */ import java.io.IOException; +import java.io.Serializable; import java.io.StringWriter; import java.io.Writer; import java.lang.reflect.Array; @@ -81,7 +82,14 @@ of this software and associated documentation files (the "Software"), to deal * @author JSON.org * @version 2016-08/15 */ -public class JSONArray implements Iterable { +public class JSONArray implements Iterable, Serializable { + + /** + * Serialization version ID. This should only be changed under certain + * circumstances, see JDK documentation details + */ + private static final long serialVersionUID = -3758785237786450861L; /** * The arrayList where the JSONArray's properties are kept. diff --git a/src/main/java/org/json/JSONObject.java b/src/main/java/org/json/JSONObject.java index b60344bad..fc02ab18a 100644 --- a/src/main/java/org/json/JSONObject.java +++ b/src/main/java/org/json/JSONObject.java @@ -1,6 +1,6 @@ package org.json; -import java.io.Closeable; +import java.io.*; /* Copyright (c) 2002 JSON.org @@ -26,9 +26,6 @@ of this software and associated documentation files (the "Software"), to deal SOFTWARE. */ -import java.io.IOException; -import java.io.StringWriter; -import java.io.Writer; import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -100,7 +97,7 @@ of this software and associated documentation files (the "Software"), to deal * @author JSON.org * @version 2016-08-15 */ -public class JSONObject { +public class JSONObject implements Serializable { /** * JSONObject.NULL is equivalent to the value that JavaScript calls null, * whilst Java's null is equivalent to the value that JavaScript calls @@ -151,7 +148,15 @@ public String toString() { return "null"; } } - + + /** + * Serialization version ID. This should only be changed under certain + * circumstances, see JDK documentation details + */ + private static final long serialVersionUID = 5240016072008648204L; + + /** * Regular Expression Pattern that matches JSON Numbers. This is primarily used for * output to guarantee that we are always writing valid JSON.