From b42daf1ba9b833c5780f89f7c021abe1a9206bac Mon Sep 17 00:00:00 2001 From: miktim Date: Sun, 13 Oct 2024 08:12:34 +0300 Subject: [PATCH] 3.0.0 --- README | 17 +++++++++++------ dist/json-3.0.0-alpha.jar | Bin 0 -> 21065 bytes src/org/miktim/json/JSON.java | 4 ++-- .../{GeneratorJSON.java => JSONGenerator.java} | 15 +++++++-------- .../json/{ParserJSON.java => JSONParser.java} | 12 +++++------- src/org/miktim/json/Json.java | 6 +++--- test/json/JsonTest.java | 2 +- 7 files changed, 29 insertions(+), 27 deletions(-) create mode 100644 dist/json-3.0.0-alpha.jar rename src/org/miktim/json/{GeneratorJSON.java => JSONGenerator.java} (90%) rename src/org/miktim/json/{ParserJSON.java => JSONParser.java} (94%) diff --git a/README b/README index 48c1833..9d2924e 100644 --- a/README +++ b/README @@ -118,13 +118,15 @@ Overview: Abstract class JsonObject; + Java objects extender. Unload/load fields of a Java object to/from a Json object. - visibility of object fields as from the object constructor, except for private fields - Java transient fields are ignored; - Java final fields are unloaded, but not initialized at load; - the accessible fields of the object MUST be initialized; - see Json set/get/cast rules for Java object fields in the notes for Json object; - - arrays of custom objects and collections MUST be managed using replacer/reviewer. + - arrays of custom objects and collections MUST be managed using replacer/reviewer; + - it is highly recommended to create a default constructor Constants: protected static final transient Object IGNORED; @@ -133,19 +135,19 @@ Overview: Methods: Json toJson() throws IllegalArgumentException, IllegalAccessException; - // returns Json object from this object + // returns a Json object from this object T fromJson(Json jsonObj) throws IllegalArgumentException, IllegalAccessException; - // load Json to this object + // loads Json to this object Json toJson(Object targetObj) throws IllegalArgumentException, IllegalAccessException; - // returns Json object from target object + // returns a Json object from the target object T fromJson(T targetObj, Json json) throws IllegalArgumentException, IllegalAccessException; - // load Json to target object + // loads Json to target object protected Object replacer(String name, Object value); - applies on unloading; @@ -160,7 +162,10 @@ Overview: - returns a value that is compatible with the object field or IGNORED protected void onError(String name, Exception e); - default action: print error message to System.err + // default action: print exception message to System.err + + String toString(); + // overriden. Generate text in JSON format as a single line protected T getTarget(); // get target object. Accessible from replacer/reviver diff --git a/dist/json-3.0.0-alpha.jar b/dist/json-3.0.0-alpha.jar new file mode 100644 index 0000000000000000000000000000000000000000..2c8f727414ea460d5664cd1ef0eede0c068b29a0 GIT binary patch literal 21065 zcmagFV|ZoJwyqo7b}FgZwr$(C?Nn^1V%xSgPaZ1Azg_imC|GO3I1Re~kkHDg0L`6p+q$s2rZw zRNZ&@_V!t|X()zoh4oZtNgaZ7k_i#bqFd#FcFJ z5NR{_J}pX)(M6L?#-|}{B{O2(YN82)MbImrfmTp)LE8pbobB!YcQn-h$^tkewXH5N5ReZD5D?z~C0a^Z zUXFy3&e+D#**Qj0R(?PL$yd4_TtrZ0D6Wt(FJdvxqdyI+Afjjhc(9w6+QzoCg!YS$ zH{IjLY5?GGl7+DcjJt1WzSZSxZ`P6R*WC@u0k8vxvBF_vU0}6gEIS^+oCOb>vp~RV zu;n~}BNcw>;=ZLJ*ho*2mI1`KoFYsL3_WH|iWws_q1pT7LfS6F3Co#o#`jA+4+)d- zY(f{;y1#W_ZAnHExf4p%3Zo7B4LVGcE4$137d_L2tt(c(W)=X74u|fQYZfG?GSJ_g zP*y&)hO`g&9mVUj_zuQfb+KXmT_y_a@vK%Tji9N7X?-O_@AiI#ZmL`!&iF)o^yPi# zS!E!NjLuZfJI~T9oXq%Cun2LPVlYG28qk9=jVh|3-hp~X0@8uNg?@AeF1Ei$JCQx% z@zHaXMl`Z@W^)^>2ytS!J;f2^`adZsNLIM2P@2~ZI;P8ow8<1ql3uiA{Dt^ew*Q$H z%$m86y6?2$fdT>H|Hrg2{3|cI^6Ly}ymIqJ@T(Mune{RBM0qHbMj%8pB*AGc3$tNz zU7gjGbe7SH$=l%czdUvzZwhB>=Bv)Q;yvoFA8$F2x2*YldH8@=h9iS$%(RxuvTHh?8&UN*m?3nrSt?WCdHPsz zqH<}y0QtHWQJ|S4SulzPTh;y?;>%e1x!x;RQ-60sh218cQ0X~$ImXrsBgO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CP2i zb5C5U7?CiNeOeizz zqqd}Z>LFKP|%dcM_NVC?G}_5tFVGGBiFrTh9} z2K!mc-3_)}uzVE6ZDT+FD*eqA_WuT7c5nSSmIoJOUt9e!as3?ge{EgME-p@m)=I@M zGuP^c%Wf`CA^N|CE2gfW)!bcOKkEzP2wbXvH+ONS%v~?VAuTIGmZ!Wjfqy^857LTk z3Wx&gi#RC3wX2|3WJW*|(2K(%EeNbaTCwB+NkG2|hZM!$?ag(1E4C9L2`IsCH)e0OENo*C;if92y0><+>q^lCEkXFL_KoT(E%^~H1S0Sy$y@4cPM3_Um zCAA7^B`^#m0VAdy(p~mC3D#q517y7@Y>jkO>Vp&odF;Rm=)k~@SC}F0LcL$ z5V$>#17twC1ApHv2c!WPlQ^_B`dnzgmX?4VU|Wg9*|m#12hd~!0)ZVF4sgF2ci`{+ XnZ2mB?EgLwj|}?;Wxo=(TYmQs6)?u6 literal 0 HcmV?d00001 diff --git a/src/org/miktim/json/JSON.java b/src/org/miktim/json/JSON.java index 2c22860..2755c49 100644 --- a/src/org/miktim/json/JSON.java +++ b/src/org/miktim/json/JSON.java @@ -50,7 +50,7 @@ public static void registerJsonObject(JsonObject obj, String className) { */ public static T toJSON(T obj, OutputStream out, int space, String charsetName) throws IOException { - GeneratorJSON generator = new GeneratorJSON(out, space, charsetName); + JSONGenerator generator = new JSONGenerator(out, space, charsetName); generator.generateObject(obj, 0); return obj; } @@ -72,7 +72,7 @@ public static String toJSON(Object obj) throws IOException { public static Object fromJSON(InputStream in, String charsetName) throws IOException, ParseException { - ParserJSON parser = new ParserJSON(in, charsetName); + JSONParser parser = new JSONParser(in, charsetName); return parser.parseObject(); } diff --git a/src/org/miktim/json/GeneratorJSON.java b/src/org/miktim/json/JSONGenerator.java similarity index 90% rename from src/org/miktim/json/GeneratorJSON.java rename to src/org/miktim/json/JSONGenerator.java index ef57917..0666b52 100644 --- a/src/org/miktim/json/GeneratorJSON.java +++ b/src/org/miktim/json/JSONGenerator.java @@ -1,13 +1,12 @@ /** * JSON generator, MIT (c) 2020-2024 miktim@mail.ru * - * Release notes: - * - generator converts to JSON Java objects: - * Json object, String, Number, Boolean, null, Object[] array of listed types; + * Generator converts to JSON Java objects: + * - Json object, String, Number, Boolean, null, Object[] array of listed types; * - Java primitives and arrays of primitives; - * - in addition, the generator converts Java Collections to JSON arrays - * and Java Maps to Json objects. The null key is converted to a "null" member name. - * Other Java objects are converted to string representation. + * - Java Collections to JSON arrays and Java Maps to Json objects. + * The null key is converted to a "null" member name; + * - Other Java objects are converted to string representation. */ package org.miktim.json; @@ -20,14 +19,14 @@ import java.util.Collection; import java.util.Map; -class GeneratorJSON { +class JSONGenerator { int intend = 0; String charsetName = "UTF-8"; OutputStream stream; byte[] newLine = "\n".getBytes(); - GeneratorJSON(OutputStream outStream, int space, String charsetName) { + JSONGenerator(OutputStream outStream, int space, String charsetName) { intend = space; this.charsetName = charsetName; stream = outStream; diff --git a/src/org/miktim/json/ParserJSON.java b/src/org/miktim/json/JSONParser.java similarity index 94% rename from src/org/miktim/json/ParserJSON.java rename to src/org/miktim/json/JSONParser.java index 16ef2ac..f5a61a8 100644 --- a/src/org/miktim/json/ParserJSON.java +++ b/src/org/miktim/json/JSONParser.java @@ -1,10 +1,8 @@ /** - * JSON parser, MIT (c) 2020 -2024 miktim@mail.ru + * JSON parser, MIT (c) 2020-2024 miktim@mail.ru * - * Release notes: - * - parser converts JSON text to Java objects: - * Json object, String, Number (Double or Long), Boolean, null, Object[] array of listed types; - * - JSON object members (name/value pairs) are stored in creation/appearance order; + * - Parser converts JSON text to Java objects: + * Json object, String, Number, Boolean, null, Object[] array of listed types; * - when the names within an object are not unique, parser stores the last value only; */ package org.miktim.json; @@ -20,12 +18,12 @@ import static java.util.Arrays.binarySearch; import java.util.List; -class ParserJSON { +class JSONParser { String charsetName; InputStream stream; - ParserJSON(InputStream inStream, String charsetName) throws UnsupportedEncodingException { + JSONParser(InputStream inStream, String charsetName) throws UnsupportedEncodingException { this.charsetName = charsetName; stream = inStream; reader = new InputStreamReader(inStream, charsetName); diff --git a/src/org/miktim/json/Json.java b/src/org/miktim/json/Json.java index fb34da9..bdf81a3 100644 --- a/src/org/miktim/json/Json.java +++ b/src/org/miktim/json/Json.java @@ -6,7 +6,7 @@ * - Java 7+, Android compatible; * - Json members: * Json object, String, Number (Double or Long), Boolean, null, Object[] array of listed types; - * - Json object setter accept all Java primitives and primitive arrays; + * - Json setters accept any Java objects, all Java primitives and primitive arrays; * - avoid recursion!. * * Created: 2020-03-07 @@ -61,8 +61,8 @@ public Json toJSON(OutputStream outStream) throws IOException { public String toString() { try { return JSON.toJSON(this); - } catch (IOException ex) { - ex.printStackTrace(); + } catch (IOException ie) { + ie.printStackTrace(); return null; } } diff --git a/test/json/JsonTest.java b/test/json/JsonTest.java index 301fe3e..11c8b1d 100644 --- a/test/json/JsonTest.java +++ b/test/json/JsonTest.java @@ -98,7 +98,7 @@ public static void main(String[] args) throws Exception { log(json.toJSON("Two")); log(json.getString("3")); log(Arrays.toString(json.getJson("Nested Json").getArray("array", 1))); - log(json.getJson("Nested Json").getNumber("array", 1, 1).intValue()); + log(json.getJson("Nested Json").getNumber("array", 1, 1)); log("\n\rTest JSON typecast."); json = (new Json())