From 514792b8eaa757afbf81968c86962efd34c2863a Mon Sep 17 00:00:00 2001 From: StaticDefault Date: Fri, 27 Sep 2019 10:05:50 +0900 Subject: [PATCH 1/5] Changed api. --- .../com/realtimetech/kson/KsonContext.java | 80 +++++++++---------- .../{KsonArray.java => JsonArray.java} | 2 +- .../{KsonObject.java => JsonObject.java} | 2 +- .../{KsonValue.java => JsonValue.java} | 6 +- .../com/realtimetech/kson/test/MainTest.java | 18 ++--- 5 files changed, 54 insertions(+), 54 deletions(-) rename src/main/java/com/realtimetech/kson/element/{KsonArray.java => JsonArray.java} (88%) rename src/main/java/com/realtimetech/kson/element/{KsonObject.java => JsonObject.java} (88%) rename src/main/java/com/realtimetech/kson/element/{KsonValue.java => JsonValue.java} (90%) diff --git a/src/main/java/com/realtimetech/kson/KsonContext.java b/src/main/java/com/realtimetech/kson/KsonContext.java index 62eb450..93d10fc 100644 --- a/src/main/java/com/realtimetech/kson/KsonContext.java +++ b/src/main/java/com/realtimetech/kson/KsonContext.java @@ -15,9 +15,9 @@ import com.realtimetech.kson.annotation.Ignore; import com.realtimetech.kson.annotation.PrimaryKey; -import com.realtimetech.kson.element.KsonArray; -import com.realtimetech.kson.element.KsonObject; -import com.realtimetech.kson.element.KsonValue; +import com.realtimetech.kson.element.JsonArray; +import com.realtimetech.kson.element.JsonObject; +import com.realtimetech.kson.element.JsonValue; import com.realtimetech.kson.exception.DeserializeException; import com.realtimetech.kson.exception.SerializeException; import com.realtimetech.kson.util.stack.FastStack; @@ -28,7 +28,7 @@ @SuppressWarnings("unchecked") public class KsonContext { - private enum ValueMode { + private static enum ValueMode { NONE, OBJECT, ARRAY, STRING, NUMBER } @@ -39,7 +39,7 @@ private enum ValueMode { // for object private FastStack objectStack; - private FastStack ksonStack; + private FastStack ksonStack; private boolean working; private boolean useCustomTag; @@ -67,7 +67,7 @@ public KsonContext(int stackSize, int stringBufferSize) { this.stringMaker = new StringMaker(stringBufferSize); this.objectStack = new FastStack(stackSize); - this.ksonStack = new FastStack(stackSize); + this.ksonStack = new FastStack(stackSize); this.useCustomTag = true; @@ -121,7 +121,7 @@ public Date deserialize(KsonContext ksonContext, Class fieldType, Object valu this.registeredTransformers.put(Collection.class, new Transformer>() { @Override public Object serialize(KsonContext ksonContext, Collection value) { - KsonArray ksonArray = new KsonArray(); + JsonArray ksonArray = new JsonArray(); for (Object object : value) { try { @@ -145,7 +145,7 @@ public Collection deserialize(KsonContext ksonContext, Class fieldType, Ob e.printStackTrace(); } - for (Object object : (KsonArray) value) { + for (Object object : (JsonArray) value) { try { collections.add(ksonContext.addToObjectStack(object.getClass(), object)); } catch (Exception e) { @@ -160,7 +160,7 @@ public Collection deserialize(KsonContext ksonContext, Class fieldType, Ob this.registeredTransformers.put(Map.class, new Transformer>() { @Override public Object serialize(KsonContext ksonContext, Map value) { - KsonObject ksonObject = new KsonObject(); + JsonObject ksonObject = new JsonObject(); for (Object keyObject : value.keySet()) { Object valueObject = value.get(keyObject); @@ -188,7 +188,7 @@ public Object serialize(KsonContext ksonContext, Map value) { e.printStackTrace(); } - KsonObject ksonObject = (KsonObject) value; + JsonObject ksonObject = (JsonObject) value; for (Object keyObject : ksonObject.keySet()) { Object valueObject = ksonObject.get(keyObject); @@ -265,7 +265,7 @@ public boolean isUseCustomTag() { return useCustomTag; } - private static final Class[] SERIALIZE_WHITE_LIST = new Class[] { KsonObject.class, KsonArray.class, boolean.class, Boolean.class, int.class, Integer.class, double.class, Double.class, float.class, Float.class, long.class, Long.class, byte.class, Byte.class, short.class, Short.class, String.class }; + private static final Class[] SERIALIZE_WHITE_LIST = new Class[] { JsonObject.class, JsonArray.class, boolean.class, Boolean.class, int.class, Integer.class, double.class, Double.class, float.class, Float.class, long.class, Long.class, byte.class, Byte.class, short.class, Short.class, String.class }; private boolean isNeedSerialize(Class clazz) { for (Class whiteClass : SERIALIZE_WHITE_LIST) { @@ -363,8 +363,8 @@ public T toObject(Class clazz, Object object) throws DeserializeException } } - if (object instanceof KsonValue) { - return (T) this.addToObjectStack(clazz, (KsonValue) object); + if (object instanceof JsonValue) { + return (T) this.addToObjectStack(clazz, (JsonValue) object); } return (T) object; @@ -381,12 +381,12 @@ public Object addToObjectStack(Class clazz, Object object) throws Deserialize this.working = true; while (!this.objectStack.isEmpty()) { Object targetObject = this.objectStack.pop(); - KsonValue targetKson = this.ksonStack.pop(); + JsonValue targetKson = this.ksonStack.pop(); Class targetObjectClass = targetObject.getClass(); - if (targetKson instanceof KsonObject) { - KsonObject ksonValue = (KsonObject) targetKson; + if (targetKson instanceof JsonObject) { + JsonObject ksonValue = (JsonObject) targetKson; for (Field field : this.getAccessibleFields(targetObjectClass)) { try { @@ -403,7 +403,7 @@ public Object addToObjectStack(Class clazz, Object object) throws Deserialize } } } else { - KsonArray ksonValue = (KsonArray) targetKson; + JsonArray ksonValue = (JsonArray) targetKson; int size = ksonValue.size(); for (int index = 0; index < size; index++) { @@ -441,8 +441,8 @@ private Object createAtToObject(boolean first, Class type, Object originalVal if (type.isEnum()) return Enum.valueOf((Class) type, originalValue.toString()); - if (originalValue instanceof KsonObject) { - KsonObject wrappingObject = (KsonObject) originalValue; + if (originalValue instanceof JsonObject) { + JsonObject wrappingObject = (JsonObject) originalValue; if (wrappingObject.containsKey("#class")) { try { @@ -478,8 +478,8 @@ private Object createAtToObject(boolean first, Class type, Object originalVal if (this.isNeedSerialize(type)) { boolean useStack = true; - if (convertedValue instanceof KsonArray) { - KsonArray ksonArray = (KsonArray) convertedValue; + if (convertedValue instanceof JsonArray) { + JsonArray ksonArray = (JsonArray) convertedValue; Class componentType = type.getComponentType(); if (componentType == null) { @@ -487,7 +487,7 @@ private Object createAtToObject(boolean first, Class type, Object originalVal } convertedValue = Array.newInstance(componentType, ksonArray.size()); - } else if (convertedValue instanceof KsonObject) { + } else if (convertedValue instanceof JsonObject) { if (primaryId == null) { try { convertedValue = UnsafeAllocator.newInstance(type); @@ -515,7 +515,7 @@ private Object createAtToObject(boolean first, Class type, Object originalVal } if (useStack && convertedValue != null) { - this.ksonStack.push((KsonValue) originalValue); + this.ksonStack.push((JsonValue) originalValue); this.objectStack.push(convertedValue); } } @@ -523,9 +523,9 @@ private Object createAtToObject(boolean first, Class type, Object originalVal return convertedValue; } - public KsonValue fromObject(Object object) throws SerializeException { + public JsonValue fromObject(Object object) throws SerializeException { if (!this.working) { - return (KsonValue) addFromObjectStack(object); + return (JsonValue) addFromObjectStack(object); } else { throw new SerializeException("This context already running serialize!"); } @@ -540,10 +540,10 @@ public Object addFromObjectStack(Object object) throws SerializeException { while (!this.objectStack.isEmpty()) { Object targetObject = this.objectStack.pop(); - KsonValue targetKson = this.ksonStack.pop(); + JsonValue targetKson = this.ksonStack.pop(); - if (targetKson instanceof KsonObject) { - KsonObject ksonValue = (KsonObject) targetKson; + if (targetKson instanceof JsonObject) { + JsonObject ksonValue = (JsonObject) targetKson; for (Field field : this.getAccessibleFields(targetObject.getClass())) { try { ksonValue.put(field.getName(), this.createAtFromObject(false, field.getType(), field.get(targetObject))); @@ -552,7 +552,7 @@ public Object addFromObjectStack(Object object) throws SerializeException { } } } else { - KsonArray ksonValue = (KsonArray) targetKson; + JsonArray ksonValue = (JsonArray) targetKson; int length = Array.getLength(targetObject); for (int index = 0; index < length; index++) { @@ -596,7 +596,7 @@ private Object createAtFromObject(boolean first, Class type, Object originalV Field primaryKeyField = getPrimaryKeyField(originalValueType); if (primaryKeyField != null) { - KsonObject wrappingObject = new KsonObject(); + JsonObject wrappingObject = new JsonObject(); try { wrappingObject.put("@id", primaryKeyField.get(originalValue)); @@ -612,17 +612,17 @@ private Object createAtFromObject(boolean first, Class type, Object originalV if (this.isNeedSerialize(convertedKsonValue.getClass())) { if (originalValue.getClass().isArray()) { - convertedKsonValue = new KsonArray(); + convertedKsonValue = new JsonArray(); } else { - convertedKsonValue = new KsonObject(); + convertedKsonValue = new JsonObject(); } this.objectStack.push(originalValue); - this.ksonStack.push((KsonValue) convertedKsonValue); + this.ksonStack.push((JsonValue) convertedKsonValue); } if (this.isNeedSerialize(originalValueType) && type != originalValueType && this.useCustomTag) { - KsonObject wrappingObject = new KsonObject(); + JsonObject wrappingObject = new JsonObject(); wrappingObject.put("#class", originalValueType.getName()); wrappingObject.put("#data", convertedKsonValue); @@ -633,7 +633,7 @@ private Object createAtFromObject(boolean first, Class type, Object originalV return convertedKsonValue; } - public KsonValue fromString(String kson) throws IOException { + public JsonValue fromString(String kson) throws IOException { this.valueStack.reset(); this.modeStack.reset(); @@ -653,11 +653,11 @@ public KsonValue fromString(String kson) throws IOException { if (currentMode == ValueMode.NONE || currentMode == ValueMode.OBJECT || currentMode == ValueMode.ARRAY) { if (!(currentChar == ' ' || currentChar == '\t' || currentChar == '\n')) { if (currentChar == '{') { - valueStack.push(new KsonObject()); + valueStack.push(new JsonObject()); modeStack.push(ValueMode.OBJECT); currentMode = modeStack.peek(); } else if (currentChar == '[') { - valueStack.push(new KsonArray()); + valueStack.push(new JsonArray()); modeStack.push(ValueMode.ARRAY); currentMode = modeStack.peek(); } else if (currentChar == '\"') { @@ -686,7 +686,7 @@ public KsonValue fromString(String kson) throws IOException { Object value = valueStack.pop(); Object key = valueStack.pop(); - KsonObject ksonObject = (KsonObject) valueStack.peek(); + JsonObject ksonObject = (JsonObject) valueStack.peek(); ksonObject.put(key, value); } @@ -700,7 +700,7 @@ public KsonValue fromString(String kson) throws IOException { if (lastValidChar != '[') { Object value = valueStack.pop(); - KsonArray ksonArray = (KsonArray) valueStack.peek(); + JsonArray ksonArray = (JsonArray) valueStack.peek(); ksonArray.add(value); } @@ -816,6 +816,6 @@ public KsonValue fromString(String kson) throws IOException { throw new IOException("An exception occurred at " + (pointer - 1) + " position character(" + charArray[(pointer - 1)] + ")"); } - return (KsonValue) valueStack.pop(); + return (JsonValue) valueStack.pop(); } } diff --git a/src/main/java/com/realtimetech/kson/element/KsonArray.java b/src/main/java/com/realtimetech/kson/element/JsonArray.java similarity index 88% rename from src/main/java/com/realtimetech/kson/element/KsonArray.java rename to src/main/java/com/realtimetech/kson/element/JsonArray.java index b14b330..2c03b0c 100644 --- a/src/main/java/com/realtimetech/kson/element/KsonArray.java +++ b/src/main/java/com/realtimetech/kson/element/JsonArray.java @@ -2,7 +2,7 @@ import java.util.ArrayList; -public class KsonArray extends ArrayList implements KsonValue { +public class JsonArray extends ArrayList implements JsonValue { /** * 기본 Serial UID diff --git a/src/main/java/com/realtimetech/kson/element/KsonObject.java b/src/main/java/com/realtimetech/kson/element/JsonObject.java similarity index 88% rename from src/main/java/com/realtimetech/kson/element/KsonObject.java rename to src/main/java/com/realtimetech/kson/element/JsonObject.java index c2088c5..5915fda 100644 --- a/src/main/java/com/realtimetech/kson/element/KsonObject.java +++ b/src/main/java/com/realtimetech/kson/element/JsonObject.java @@ -2,7 +2,7 @@ import java.util.HashMap; -public class KsonObject extends HashMap implements KsonValue { +public class JsonObject extends HashMap implements JsonValue { /** * 기본 Serial UID diff --git a/src/main/java/com/realtimetech/kson/element/KsonValue.java b/src/main/java/com/realtimetech/kson/element/JsonValue.java similarity index 90% rename from src/main/java/com/realtimetech/kson/element/KsonValue.java rename to src/main/java/com/realtimetech/kson/element/JsonValue.java index 68210dd..b8e76c5 100644 --- a/src/main/java/com/realtimetech/kson/element/KsonValue.java +++ b/src/main/java/com/realtimetech/kson/element/JsonValue.java @@ -2,7 +2,7 @@ import com.realtimetech.kson.util.string.StringMaker; -public interface KsonValue { +public interface JsonValue { StringMaker stringMaker = new StringMaker(); default public String toKsonString() { @@ -62,8 +62,8 @@ default public String toString(Object object, boolean useKsonStandard) { if (object == null) return "null"; - if (object instanceof KsonValue) { - KsonValue ksonValue = (KsonValue) object; + if (object instanceof JsonValue) { + JsonValue ksonValue = (JsonValue) object; return ksonValue.toString(useKsonStandard); } else if (object instanceof String) { String string = (String) object; diff --git a/src/main/java/com/realtimetech/kson/test/MainTest.java b/src/main/java/com/realtimetech/kson/test/MainTest.java index e1acbd2..1bcca5b 100644 --- a/src/main/java/com/realtimetech/kson/test/MainTest.java +++ b/src/main/java/com/realtimetech/kson/test/MainTest.java @@ -2,8 +2,8 @@ import com.realtimetech.kson.KsonContext; import com.realtimetech.kson.builder.KsonBuilder; -import com.realtimetech.kson.element.KsonObject; -import com.realtimetech.kson.element.KsonValue; +import com.realtimetech.kson.element.JsonObject; +import com.realtimetech.kson.element.JsonValue; import com.realtimetech.kson.exception.SerializeException; import com.realtimetech.kson.util.pool.KsonPool; @@ -25,7 +25,7 @@ public void run() { System.out.println(" Context Start: " + ksonContext); for (int i = 0; i < 100000; i++) { try { - KsonValue fromObject = ksonContext.fromObject(testObject); + JsonValue fromObject = ksonContext.fromObject(testObject); } catch (SerializeException e) { e.printStackTrace(); } @@ -53,10 +53,10 @@ public void run() { System.out.println("## First Converting"); System.out.println(); - KsonObject testObjectKsonObject1 = (KsonObject) ksonContext.fromObject(testObject1); + JsonObject testObjectKsonObject1 = (JsonObject) ksonContext.fromObject(testObject1); System.out.println(" TestObject\t: " + testObjectKsonObject1); - KsonObject testKsonObject1 = (KsonObject) ksonContext.fromObject(test1); + JsonObject testKsonObject1 = (JsonObject) ksonContext.fromObject(test1); System.out.println(" Test\t\t: " + testKsonObject1); System.out.println(); @@ -84,10 +84,10 @@ public void run() { } System.out.println(); - KsonObject testObjectKsonObject2 = (KsonObject) ksonContext.fromObject(testObject2); + JsonObject testObjectKsonObject2 = (JsonObject) ksonContext.fromObject(testObject2); System.out.println(" TestObject\t: " + testObjectKsonObject2); - KsonObject testKsonObject2 = (KsonObject) ksonContext.fromObject(test1); + JsonObject testKsonObject2 = (JsonObject) ksonContext.fromObject(test1); System.out.println(" Test\t\t: " + testKsonObject2); System.out.println(); @@ -107,9 +107,9 @@ public void run() { TestObject collectObject = new TestObject(new Test(10, "100")); Long startTime = System.currentTimeMillis(); for (int i = 0; i < 1000000; i++) { - KsonObject fromObject = (KsonObject) ksonContext.fromObject(collectObject); + JsonObject fromObject = (JsonObject) ksonContext.fromObject(collectObject); TestObject good = ksonContext.toObject(TestObject.class, fromObject.toKsonString()); - KsonObject toObject = (KsonObject) ksonContext.fromObject(good); + JsonObject toObject = (JsonObject) ksonContext.fromObject(good); } Long endTime = System.currentTimeMillis(); From c2822aa806851c6cf1e7dd4ad47223fa5fc7779c Mon Sep 17 00:00:00 2001 From: StaticDefault Date: Fri, 27 Sep 2019 10:10:02 +0900 Subject: [PATCH 2/5] Changed variable name. --- .../com/realtimetech/kson/KsonContext.java | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/src/main/java/com/realtimetech/kson/KsonContext.java b/src/main/java/com/realtimetech/kson/KsonContext.java index 93d10fc..a55372e 100644 --- a/src/main/java/com/realtimetech/kson/KsonContext.java +++ b/src/main/java/com/realtimetech/kson/KsonContext.java @@ -121,17 +121,17 @@ public Date deserialize(KsonContext ksonContext, Class fieldType, Object valu this.registeredTransformers.put(Collection.class, new Transformer>() { @Override public Object serialize(KsonContext ksonContext, Collection value) { - JsonArray ksonArray = new JsonArray(); + JsonArray jsonArray = new JsonArray(); for (Object object : value) { try { - ksonArray.add(ksonContext.addFromObjectStack(object)); + jsonArray.add(ksonContext.addFromObjectStack(object)); } catch (SerializeException e) { e.printStackTrace(); } } - return ksonArray; + return jsonArray; } @SuppressWarnings("deprecation") @@ -160,7 +160,7 @@ public Collection deserialize(KsonContext ksonContext, Class fieldType, Ob this.registeredTransformers.put(Map.class, new Transformer>() { @Override public Object serialize(KsonContext ksonContext, Map value) { - JsonObject ksonObject = new JsonObject(); + JsonObject jsonObject = new JsonObject(); for (Object keyObject : value.keySet()) { Object valueObject = value.get(keyObject); @@ -168,13 +168,13 @@ public Object serialize(KsonContext ksonContext, Map value) { try { Object keyKson = ksonContext.addFromObjectStack(keyObject); Object valueKson = ksonContext.addFromObjectStack(valueObject); - ksonObject.put(keyKson, valueKson); + jsonObject.put(keyKson, valueKson); } catch (SerializeException e) { e.printStackTrace(); } } - return ksonObject; + return jsonObject; } @SuppressWarnings("deprecation") @@ -188,9 +188,9 @@ public Object serialize(KsonContext ksonContext, Map value) { e.printStackTrace(); } - JsonObject ksonObject = (JsonObject) value; - for (Object keyObject : ksonObject.keySet()) { - Object valueObject = ksonObject.get(keyObject); + JsonObject jsonObject = (JsonObject) value; + for (Object keyObject : jsonObject.keySet()) { + Object valueObject = jsonObject.get(keyObject); try { map.put(ksonContext.addToObjectStack(keyObject.getClass(), keyObject), ksonContext.addToObjectStack(valueObject.getClass(), valueObject)); @@ -386,11 +386,11 @@ public Object addToObjectStack(Class clazz, Object object) throws Deserialize Class targetObjectClass = targetObject.getClass(); if (targetKson instanceof JsonObject) { - JsonObject ksonValue = (JsonObject) targetKson; + JsonObject jsonValue = (JsonObject) targetKson; for (Field field : this.getAccessibleFields(targetObjectClass)) { try { - Object createAtToObject = createAtToObject(false, field.getType(), ksonValue.get(field.getName())); + Object createAtToObject = createAtToObject(false, field.getType(), jsonValue.get(field.getName())); if (createAtToObject.getClass() != field.getType()) { createAtToObject = castToType(field.getType(), createAtToObject); @@ -403,8 +403,8 @@ public Object addToObjectStack(Class clazz, Object object) throws Deserialize } } } else { - JsonArray ksonValue = (JsonArray) targetKson; - int size = ksonValue.size(); + JsonArray jsonValue = (JsonArray) targetKson; + int size = jsonValue.size(); for (int index = 0; index < size; index++) { Class arrayComponentType = targetObjectClass.getComponentType(); @@ -413,7 +413,7 @@ public Object addToObjectStack(Class clazz, Object object) throws Deserialize arrayComponentType = targetObjectClass; } - Object createAtToObject = createAtToObject(false, arrayComponentType, ksonValue.get(index)); + Object createAtToObject = createAtToObject(false, arrayComponentType, jsonValue.get(index)); if (createAtToObject.getClass() != arrayComponentType) { createAtToObject = castToType(arrayComponentType, createAtToObject); @@ -479,14 +479,14 @@ private Object createAtToObject(boolean first, Class type, Object originalVal boolean useStack = true; if (convertedValue instanceof JsonArray) { - JsonArray ksonArray = (JsonArray) convertedValue; + JsonArray jsonArray = (JsonArray) convertedValue; Class componentType = type.getComponentType(); if (componentType == null) { componentType = type.getClass(); } - convertedValue = Array.newInstance(componentType, ksonArray.size()); + convertedValue = Array.newInstance(componentType, jsonArray.size()); } else if (convertedValue instanceof JsonObject) { if (primaryId == null) { try { @@ -543,16 +543,16 @@ public Object addFromObjectStack(Object object) throws SerializeException { JsonValue targetKson = this.ksonStack.pop(); if (targetKson instanceof JsonObject) { - JsonObject ksonValue = (JsonObject) targetKson; + JsonObject jsonValue = (JsonObject) targetKson; for (Field field : this.getAccessibleFields(targetObject.getClass())) { try { - ksonValue.put(field.getName(), this.createAtFromObject(false, field.getType(), field.get(targetObject))); + jsonValue.put(field.getName(), this.createAtFromObject(false, field.getType(), field.get(targetObject))); } catch (IllegalArgumentException | IllegalAccessException e) { throw new SerializeException("Serialize failed because object could can't get from field."); } } } else { - JsonArray ksonValue = (JsonArray) targetKson; + JsonArray jsonValue = (JsonArray) targetKson; int length = Array.getLength(targetObject); for (int index = 0; index < length; index++) { @@ -562,7 +562,7 @@ public Object addFromObjectStack(Object object) throws SerializeException { arrayComponentType = targetObject.getClass(); } - ksonValue.add(this.createAtFromObject(false, arrayComponentType, ArrayAccessor.get(targetObject, index))); + jsonValue.add(this.createAtFromObject(false, arrayComponentType, ArrayAccessor.get(targetObject, index))); } } } @@ -686,8 +686,8 @@ public JsonValue fromString(String kson) throws IOException { Object value = valueStack.pop(); Object key = valueStack.pop(); - JsonObject ksonObject = (JsonObject) valueStack.peek(); - ksonObject.put(key, value); + JsonObject jsonObject = (JsonObject) valueStack.peek(); + jsonObject.put(key, value); } if (currentChar == '}') { @@ -700,8 +700,8 @@ public JsonValue fromString(String kson) throws IOException { if (lastValidChar != '[') { Object value = valueStack.pop(); - JsonArray ksonArray = (JsonArray) valueStack.peek(); - ksonArray.add(value); + JsonArray jsonArray = (JsonArray) valueStack.peek(); + jsonArray.add(value); } if (currentChar == ']') { From 4a8d75a7779abd420e1ddb80f2c06afbfdeeba71 Mon Sep 17 00:00:00 2001 From: Park JeongHwan Date: Fri, 27 Sep 2019 10:10:40 +0900 Subject: [PATCH 3/5] Update README.md --- README.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index fd3d493..b715b48 100644 --- a/README.md +++ b/README.md @@ -115,38 +115,38 @@ KsonPool ksonPool = new KsonPool(ksonBuilder); KsonContext ksonContext = ksonPool.get(); ``` -#### 2.2.2. String to KsonValue +#### 2.2.2. String to JsonValue ``` KsonContext ksonContext = new KsonContext(); String jsonString = "{...}"; -KsonValue ksonValue = ksonContext.fromString(jsonString); +JsonValue JsonValue = ksonContext.fromString(jsonString); ``` -#### 2.2.3. KsonValue to String +#### 2.2.3. JsonValue to String ``` -KsonValue ksonValue = ...; -String jsonString = ksonValue.toJsonString(); //일반적인 Json 포맷을 이용합니다. -String ksonString = ksonValue.toKsonString(); //확장된 Kson 포맷을 이용합니다. +JsonValue JsonValue = ...; +String jsonString = JsonValue.toJsonString(); //일반적인 Json 포맷을 이용합니다. +String ksonString = JsonValue.toKsonString(); //확장된 Kson 포맷을 이용합니다. ``` -#### 2.2.4. Object to KsonValue +#### 2.2.4. Object to JsonValue ``` KsonContext ksonContext = new KsonContext(); Person personObject = someObject; -KsonValue ksonValue = ksonContext.fromObject(personObject); +JsonValue JsonValue = ksonContext.fromObject(personObject); ``` -#### 2.2.5. KsonValue to Object +#### 2.2.5. JsonValue to Object ``` KsonContext ksonContext = new KsonContext(); -KsonValue ksonValue = ...; -Person personObject = ksonContext.toObject(Person.class, ksonValue); +JsonValue JsonValue = ...; +Person personObject = ksonContext.toObject(Person.class, JsonValue); ``` -#### 2.2.6. String to (KsonValue) to Object +#### 2.2.6. String to (JsonValue) to Object ``` KsonContext ksonContext = new KsonContext(); From f04e14e32d100d3e544749a2354c988ff50a1d4c Mon Sep 17 00:00:00 2001 From: Park JeongHwan Date: Fri, 27 Sep 2019 10:11:46 +0900 Subject: [PATCH 4/5] Update README_EN.md --- README_EN.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/README_EN.md b/README_EN.md index a502250..38add92 100644 --- a/README_EN.md +++ b/README_EN.md @@ -98,38 +98,38 @@ KsonPool ksonPool = new KsonPool(ksonBuilder); KsonContext ksonContext = ksonPool.get(); ``` -#### 2.2.2. String to KsonValue +#### 2.2.2. String to JsonValue ``` KsonContext ksonContext = new KsonContext(); String jsonString = "{...}"; -KsonValue ksonValue = ksonContext.fromString(jsonString); +JsonValue jsonValue = ksonContext.fromString(jsonString); ``` -#### 2.2.3. KsonValue to String +#### 2.2.3. JsonValue to String ``` -KsonValue ksonValue = ...; -String jsonString = ksonValue.toJsonString(); //Usage of standard Json format. -String ksonString = ksonValue.toKsonString(); //Usage of extended Kson format. +JsonValue jsonValue = ...; +String jsonString = jsonValue.toJsonString(); //Usage of standard Json format. +String ksonString = jsonValue.toKsonString(); //Usage of extended Kson format. ``` -#### 2.2.4. Object to KsonValue +#### 2.2.4. Object to JsonValue ``` KsonContext ksonContext = new KsonContext(); Person personObject = someObject; -KsonValue ksonValue = ksonContext.fromObject(personObject); +JsonValue jsonValue = ksonContext.fromObject(personObject); ``` -#### 2.2.5. KsonValue to Object +#### 2.2.5. JsonValue to Object ``` KsonContext ksonContext = new KsonContext(); -KsonValue ksonValue = ...; -Person personObject = ksonContext.toObject(Person.class, ksonValue); +JsonValue jsonValue = ...; +Person personObject = ksonContext.toObject(Person.class, jsonValue); ``` -#### 2.2.6. String to (KsonValue) to Object +#### 2.2.6. String to (JsonValue) to Object ``` KsonContext ksonContext = new KsonContext(); From 5f51e12fed47ec13f463df50a99723eb6b21fa4e Mon Sep 17 00:00:00 2001 From: StaticDefault Date: Fri, 27 Sep 2019 10:13:55 +0900 Subject: [PATCH 5/5] Changed stack variable name. --- .../java/com/realtimetech/kson/KsonContext.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/java/com/realtimetech/kson/KsonContext.java b/src/main/java/com/realtimetech/kson/KsonContext.java index a55372e..439625b 100644 --- a/src/main/java/com/realtimetech/kson/KsonContext.java +++ b/src/main/java/com/realtimetech/kson/KsonContext.java @@ -39,7 +39,7 @@ private static enum ValueMode { // for object private FastStack objectStack; - private FastStack ksonStack; + private FastStack jsonStack; private boolean working; private boolean useCustomTag; @@ -67,7 +67,7 @@ public KsonContext(int stackSize, int stringBufferSize) { this.stringMaker = new StringMaker(stringBufferSize); this.objectStack = new FastStack(stackSize); - this.ksonStack = new FastStack(stackSize); + this.jsonStack = new FastStack(stackSize); this.useCustomTag = true; @@ -381,7 +381,7 @@ public Object addToObjectStack(Class clazz, Object object) throws Deserialize this.working = true; while (!this.objectStack.isEmpty()) { Object targetObject = this.objectStack.pop(); - JsonValue targetKson = this.ksonStack.pop(); + JsonValue targetKson = this.jsonStack.pop(); Class targetObjectClass = targetObject.getClass(); @@ -425,7 +425,7 @@ public Object addToObjectStack(Class clazz, Object object) throws Deserialize } this.working = false; this.objectStack.reset(); - this.ksonStack.reset(); + this.jsonStack.reset(); } return result; @@ -515,7 +515,7 @@ private Object createAtToObject(boolean first, Class type, Object originalVal } if (useStack && convertedValue != null) { - this.ksonStack.push((JsonValue) originalValue); + this.jsonStack.push((JsonValue) originalValue); this.objectStack.push(convertedValue); } } @@ -540,7 +540,7 @@ public Object addFromObjectStack(Object object) throws SerializeException { while (!this.objectStack.isEmpty()) { Object targetObject = this.objectStack.pop(); - JsonValue targetKson = this.ksonStack.pop(); + JsonValue targetKson = this.jsonStack.pop(); if (targetKson instanceof JsonObject) { JsonObject jsonValue = (JsonObject) targetKson; @@ -568,7 +568,7 @@ public Object addFromObjectStack(Object object) throws SerializeException { } this.objectStack.reset(); - this.ksonStack.reset(); + this.jsonStack.reset(); this.working = false; } else { result = this.createAtFromObject(false, Object.class, object); @@ -618,7 +618,7 @@ private Object createAtFromObject(boolean first, Class type, Object originalV } this.objectStack.push(originalValue); - this.ksonStack.push((JsonValue) convertedKsonValue); + this.jsonStack.push((JsonValue) convertedKsonValue); } if (this.isNeedSerialize(originalValueType) && type != originalValueType && this.useCustomTag) {