diff --git a/.gitignore b/.gitignore index 286679a..24c491d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,22 +1,7 @@ - -/json-smart/target -/json-smart/.settings -/json-smart/.classpath -/json-smart/.project -/parent/.project -/parent/.settings -/json-smart/src/test/java/asm -/asm/.classpath -/asm/.project -/asm/.settings -/asm/targetjson-smart-backport/.classpath -json-smart-backport/.project -json-smart-backport/.settings -asm/target/ -json-smart-backport/target/ -json-smart/target/ -**/.project +**/.classpath +**/.idea/ +**/.project +**/.settings/ +**/*.iml **/bin -*.classpath -*.project -*.prefs +**/target diff --git a/accessors-smart/pom.xml b/accessors-smart/pom.xml index baf9570..4571fb6 100644 --- a/accessors-smart/pom.xml +++ b/accessors-smart/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.minidev accessors-smart - 1.1 + 1.2 ASM based accessors helper used by json-smart Java reflect give poor performance on getter setter an constructor calls, accessors-smart use ASM to speed up those calls. diff --git a/accessors-smart/src/main/java/net/minidev/asm/ConvertDate.java b/accessors-smart/src/main/java/net/minidev/asm/ConvertDate.java index f94e9bd..7de2822 100644 --- a/accessors-smart/src/main/java/net/minidev/asm/ConvertDate.java +++ b/accessors-smart/src/main/java/net/minidev/asm/ConvertDate.java @@ -8,6 +8,7 @@ import java.util.HashSet; import java.util.Locale; import java.util.StringTokenizer; +import java.util.TimeZone; import java.util.TreeMap; public class ConvertDate { @@ -40,6 +41,7 @@ private static Integer parseMonth(String s1) { static { voidData.add("CET"); voidData.add("MEZ"); + voidData.add("PST"); voidData.add("Uhr"); voidData.add("h"); voidData.add("pm"); @@ -118,6 +120,8 @@ public static Date convertToDate(Object obj) { return null; if (obj instanceof Date) return (Date) obj; + if (obj instanceof Number) + return new Date(((Number)obj).longValue()); if (obj instanceof String) { StringTokenizer st = new StringTokenizer((String) obj, " -/:,.+"); String s1 = ""; @@ -204,8 +208,12 @@ private static Date getMMDDYYYY(StringTokenizer st, String s1) { return null; s1 = st.nextToken(); } - cal.set(Calendar.YEAR, getYear(s1)); - + if (s1.length() == 4) + cal.set(Calendar.YEAR, getYear(s1)); + else if (s1.length() == 2) { + return addHour2(st, cal, s1); + + } // /if (st.hasMoreTokens()) // return null; // s1 = st.nextToken(); @@ -236,6 +244,10 @@ private static Date addHour(StringTokenizer st, Calendar cal, String s1) { return cal.getTime(); s1 = st.nextToken(); } + return addHour2(st, cal, s1); + } + + private static Date addHour2(StringTokenizer st, Calendar cal, String s1) { cal.set(Calendar.HOUR_OF_DAY, Integer.parseInt(s1)); if (!st.hasMoreTokens()) @@ -273,6 +285,10 @@ private static Date addHour(StringTokenizer st, Calendar cal, String s1) { s1 = trySkip(st, s1, cal); // if (s1.equalsIgnoreCase("pm")) // cal.add(Calendar.HOUR_OF_DAY, 12); + + if (s1.length() == 4 && Character.isDigit(s1.charAt(0))) + cal.set(Calendar.YEAR, getYear(s1)); + return cal.getTime(); } @@ -280,6 +296,8 @@ private static String trySkip(StringTokenizer st, String s1, Calendar cal) { while (voidData.contains(s1)) { if (s1.equalsIgnoreCase("pm")) cal.add(Calendar.HOUR_OF_DAY, 12); + if (s1.equalsIgnoreCase("PST")) + cal.setTimeZone(TimeZone.getTimeZone("PST")); if (!st.hasMoreTokens()) return null; s1 = st.nextToken(); diff --git a/accessors-smart/src/test/java/net/minidev/asm/TestDateConvert.java b/accessors-smart/src/test/java/net/minidev/asm/TestDateConvert.java index af34745..df54664 100644 --- a/accessors-smart/src/test/java/net/minidev/asm/TestDateConvert.java +++ b/accessors-smart/src/test/java/net/minidev/asm/TestDateConvert.java @@ -17,6 +17,7 @@ public void testDateFR() throws Exception { tests.add("23 janvier 2012 13:42:12"); tests.add("lundi 23 janvier 2012 13:42:12"); tests.add("2012-01-23 13:42:12"); + tests.add("Thu Jan 23 13:42:12 PST 2012"); // for (String testDate : tests) { Date parsed = null; diff --git a/json-smart/pom.xml b/json-smart/pom.xml index 6f8ef20..a7d9430 100644 --- a/json-smart/pom.xml +++ b/json-smart/pom.xml @@ -3,7 +3,7 @@ 4.0.0 net.minidev json-smart - 2.2.1 + 2.2.2 JSON Small and Fast Parser JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language. @@ -47,7 +47,7 @@ net.minidev accessors-smart - 1.1 + 1.2 @@ -95,7 +95,7 @@ 2C8DF6EC - + @@ -264,4 +264,4 @@ - \ No newline at end of file + diff --git a/json-smart/src/main/java/net/minidev/json/JSONArray.java b/json-smart/src/main/java/net/minidev/json/JSONArray.java index 350d491..1803768 100644 --- a/json-smart/src/main/java/net/minidev/json/JSONArray.java +++ b/json-smart/src/main/java/net/minidev/json/JSONArray.java @@ -24,8 +24,8 @@ /** * A JSON array. JSONObject supports java.util.List interface. * - * @author FangYidong - * @author Uriel Chemouni + * @author FangYidong <fangyidong@yahoo.com.cn> + * @author Uriel Chemouni <uchemouni@gmail.com> */ public class JSONArray extends ArrayList implements List, JSONAwareEx, JSONStreamAwareEx { private static final long serialVersionUID = 9106884089231309568L; diff --git a/json-smart/src/main/java/net/minidev/json/JSONAware.java b/json-smart/src/main/java/net/minidev/json/JSONAware.java index 4f1fd04..ba39dfb 100644 --- a/json-smart/src/main/java/net/minidev/json/JSONAware.java +++ b/json-smart/src/main/java/net/minidev/json/JSONAware.java @@ -19,7 +19,7 @@ * Beans that support customized output of JSON text shall implement this * interface. * - * @author FangYidong + * @author FangYidong <fangyidong@yahoo.com.cn> */ public interface JSONAware { /** diff --git a/json-smart/src/main/java/net/minidev/json/JSONAwareEx.java b/json-smart/src/main/java/net/minidev/json/JSONAwareEx.java index ca714b4..9292e76 100644 --- a/json-smart/src/main/java/net/minidev/json/JSONAwareEx.java +++ b/json-smart/src/main/java/net/minidev/json/JSONAwareEx.java @@ -20,7 +20,7 @@ * * Adding compressions and formating features * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ public interface JSONAwareEx extends JSONAware{ diff --git a/json-smart/src/main/java/net/minidev/json/JSONNavi.java b/json-smart/src/main/java/net/minidev/json/JSONNavi.java index 55a99ea..7a5b378 100644 --- a/json-smart/src/main/java/net/minidev/json/JSONNavi.java +++ b/json-smart/src/main/java/net/minidev/json/JSONNavi.java @@ -27,7 +27,7 @@ * * @since 1.0.9 * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ public class JSONNavi { private JsonReaderI mapper; diff --git a/json-smart/src/main/java/net/minidev/json/JSONObject.java b/json-smart/src/main/java/net/minidev/json/JSONObject.java index e9ae547..312e123 100644 --- a/json-smart/src/main/java/net/minidev/json/JSONObject.java +++ b/json-smart/src/main/java/net/minidev/json/JSONObject.java @@ -25,8 +25,8 @@ * A JSON object. Key value pairs are unordered. JSONObject supports * java.util.Map interface. * - * @author FangYidong - * @author Uriel Chemouni + * @author FangYidong <fangyidong@yahoo.com.cn> + * @author Uriel Chemouni <uchemouni@gmail.com> */ public class JSONObject extends HashMap implements JSONAware, JSONAwareEx, JSONStreamAwareEx { private static final long serialVersionUID = -503443796854799292L; @@ -113,7 +113,6 @@ public String getAsString(String key) { /** * A Simple Helper cast an Object to an Number * - * @see net.minidev.json.parser.JSONParserBase#parseNumber(String s) * @return a Number or null */ public Number getAsNumber(String key) { diff --git a/json-smart/src/main/java/net/minidev/json/JSONStreamAware.java b/json-smart/src/main/java/net/minidev/json/JSONStreamAware.java index 7d746ea..493d99b 100644 --- a/json-smart/src/main/java/net/minidev/json/JSONStreamAware.java +++ b/json-smart/src/main/java/net/minidev/json/JSONStreamAware.java @@ -21,7 +21,7 @@ * Beans that support customized output of JSON text to a writer shall implement * this interface. * - * @author FangYidong + * @author FangYidong <fangyidong@yahoo.com.cn> */ public interface JSONStreamAware { /** diff --git a/json-smart/src/main/java/net/minidev/json/JSONStreamAwareEx.java b/json-smart/src/main/java/net/minidev/json/JSONStreamAwareEx.java index b35f894..d4482d3 100644 --- a/json-smart/src/main/java/net/minidev/json/JSONStreamAwareEx.java +++ b/json-smart/src/main/java/net/minidev/json/JSONStreamAwareEx.java @@ -21,7 +21,7 @@ * Beans that support customized output of JSON text to a writer shall implement * this interface. * - * @author FangYidong + * @author FangYidong <fangyidong@yahoo.com.cn> */ public interface JSONStreamAwareEx extends JSONStreamAware { /** diff --git a/json-smart/src/main/java/net/minidev/json/JSONStyle.java b/json-smart/src/main/java/net/minidev/json/JSONStyle.java index fbd3f71..9350d18 100644 --- a/json-smart/src/main/java/net/minidev/json/JSONStyle.java +++ b/json-smart/src/main/java/net/minidev/json/JSONStyle.java @@ -23,7 +23,7 @@ /** * JSONStyle object configure JSonSerializer reducing output size * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ public class JSONStyle { /** @@ -57,7 +57,7 @@ public class JSONStyle { private boolean _protect4Web; private boolean _protectValues; private boolean _ignore_null; - + private MustProtect mpKey; private MustProtect mpValue; diff --git a/json-smart/src/main/java/net/minidev/json/JSONValue.java b/json-smart/src/main/java/net/minidev/json/JSONValue.java index 6ee5641..c26ef32 100644 --- a/json-smart/src/main/java/net/minidev/json/JSONValue.java +++ b/json-smart/src/main/java/net/minidev/json/JSONValue.java @@ -42,7 +42,7 @@ * The most commonly use methode are {@link #parse(String)} * {@link #toJSONString(Object)} * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ public class JSONValue { /** diff --git a/json-smart/src/main/java/net/minidev/json/JStylerObj.java b/json-smart/src/main/java/net/minidev/json/JStylerObj.java index 6dfdf34..0d69b8e 100644 --- a/json-smart/src/main/java/net/minidev/json/JStylerObj.java +++ b/json-smart/src/main/java/net/minidev/json/JStylerObj.java @@ -20,7 +20,7 @@ /** * protected class used to stored Internal methods * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ class JStylerObj { @@ -181,7 +181,13 @@ public static boolean isSpecial(char c) { } public static boolean isUnicode(char c) { - return ((c >= '\u0000' && c <= '\u001F') || (c >= '\u007F' && c <= '\u009F') || (c >= '\u2000' && c <= '\u20FF')); + // ANSI controle char + return ((c >= '\u0000' && c <= '\u001F') || + // DEL or unicode ctrl + (c >= '\u007F' && c <= '\u009F') || + // '\u00A0' No-breakable space ? + // En Quad .. more + (c >= '\u2000' && c <= '\u20FF')); } public static boolean isKeyword(String s) { diff --git a/json-smart/src/main/java/net/minidev/json/parser/JSONParser.java b/json-smart/src/main/java/net/minidev/json/parser/JSONParser.java index 808f8f9..4ec8531 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/JSONParser.java +++ b/json-smart/src/main/java/net/minidev/json/parser/JSONParser.java @@ -80,6 +80,14 @@ public class JSONParser { * @since 2.0.1 */ public final static int ACCEPT_TAILLING_SPACE = 512; + /** + * smart mode, fastest parsing mode. accept lots of non standard json syntax + * + * @since 2.2.2 + */ + public final static int REJECT_127_CHAR = 1024; + + /** * smart mode, fastest parsing mode. accept lots of non standard json syntax * @@ -101,13 +109,13 @@ public class JSONParser { * * @since 1.0.7 */ - public final static int MODE_JSON_SIMPLE = ACCEPT_USELESS_COMMA | USE_HI_PRECISION_FLOAT | ACCEPT_TAILLING_DATA | ACCEPT_TAILLING_SPACE; + public final static int MODE_JSON_SIMPLE = ACCEPT_USELESS_COMMA | USE_HI_PRECISION_FLOAT | ACCEPT_TAILLING_DATA | ACCEPT_TAILLING_SPACE | REJECT_127_CHAR; /** * Strictest parsing mode * * @since 2.0.1 */ - public final static int MODE_STRICTEST = USE_INTEGER_STORAGE | USE_HI_PRECISION_FLOAT; + public final static int MODE_STRICTEST = USE_INTEGER_STORAGE | USE_HI_PRECISION_FLOAT | REJECT_127_CHAR; /** * Default json-smart processing mode */ diff --git a/json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java b/json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java index c6afd11..965449a 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java +++ b/json-smart/src/main/java/net/minidev/json/parser/JSONParserBase.java @@ -25,6 +25,8 @@ import java.math.BigDecimal; import java.math.BigInteger; +import org.omg.stub.java.rmi._Remote_Stub; + import net.minidev.json.writer.JsonReader; import net.minidev.json.writer.JsonReaderI; @@ -35,7 +37,7 @@ * @see JSONParserMemory * @see JSONParserStream * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ abstract class JSONParserBase { protected char c; @@ -82,6 +84,7 @@ abstract class JSONParserBase { protected final boolean ignoreControlChar; protected final boolean useHiPrecisionFloat; protected final boolean useIntegerStorage; + protected final boolean reject127; public JSONParserBase(int permissiveMode) { this.acceptNaN = (permissiveMode & JSONParser.ACCEPT_NAN) > 0; @@ -94,6 +97,7 @@ public JSONParserBase(int permissiveMode) { this.useHiPrecisionFloat = (permissiveMode & JSONParser.USE_HI_PRECISION_FLOAT) > 0; this.checkTaillingData = (permissiveMode & (JSONParser.ACCEPT_TAILLING_DATA | JSONParser.ACCEPT_TAILLING_SPACE)) != (JSONParser.ACCEPT_TAILLING_DATA | JSONParser.ACCEPT_TAILLING_SPACE); this.checkTaillingSpace = (permissiveMode & JSONParser.ACCEPT_TAILLING_SPACE) == 0; + this.reject127 = (permissiveMode & JSONParser.REJECT_127_CHAR) > 0; } public void checkControleChar() throws ParseException { @@ -106,8 +110,10 @@ public void checkControleChar() throws ParseException { continue; if (c <= 31) throw new ParseException(pos + i, ParseException.ERROR_UNEXPECTED_CHAR, c); - if (c == 127) - throw new ParseException(pos + i, ParseException.ERROR_UNEXPECTED_CHAR, c); + if (c == 127) { + if (reject127) + throw new ParseException(pos + i, ParseException.ERROR_UNEXPECTED_CHAR, c); + } } } @@ -656,16 +662,20 @@ protected void readString2() throws ParseException, IOException { case (char) 23: // End transmission block, not the same as EOT case (char) 24: // Cancel line, MPE echoes !!! case (char) 25: // End of medium, Control-Y interrupt - // case (char) 26: // Substitute + // case (char) 26: // Substitute == EOI case (char) 27: // escape case (char) 28: // File Separator case (char) 29: // Group Separator case (char) 30: // Record Separator case (char) 31: // Unit Separator + if (ignoreControlChar) + continue; + throw new ParseException(pos, ERROR_UNEXPECTED_CHAR, c); case (char) 127: // del if (ignoreControlChar) continue; - throw new ParseException(pos, ERROR_UNEXPECTED_CHAR, c); + if (reject127) + throw new ParseException(pos, ERROR_UNEXPECTED_CHAR, c); default: sb.append(c); } diff --git a/json-smart/src/main/java/net/minidev/json/parser/JSONParserByteArray.java b/json-smart/src/main/java/net/minidev/json/parser/JSONParserByteArray.java index 1849116..80f587e 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/JSONParserByteArray.java +++ b/json-smart/src/main/java/net/minidev/json/parser/JSONParserByteArray.java @@ -22,7 +22,7 @@ /** * Parser for JSON text. Please note that JSONParser is NOT thread-safe. * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ class JSONParserByteArray extends JSONParserMemory { private byte[] in; diff --git a/json-smart/src/main/java/net/minidev/json/parser/JSONParserInputStream.java b/json-smart/src/main/java/net/minidev/json/parser/JSONParserInputStream.java index 31ca4d3..1c88f4d 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/JSONParserInputStream.java +++ b/json-smart/src/main/java/net/minidev/json/parser/JSONParserInputStream.java @@ -24,7 +24,7 @@ /** * Parser for JSON text. Please note that JSONParser is NOT thread-safe. * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ class JSONParserInputStream extends JSONParserReader { diff --git a/json-smart/src/main/java/net/minidev/json/parser/JSONParserMemory.java b/json-smart/src/main/java/net/minidev/json/parser/JSONParserMemory.java index 31cc162..356987c 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/JSONParserMemory.java +++ b/json-smart/src/main/java/net/minidev/json/parser/JSONParserMemory.java @@ -24,7 +24,7 @@ /** * Parser for JSON text. Please note that JSONParser is NOT thread-safe. * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> * @see JSONParserString * @see JSONParserByteArray */ diff --git a/json-smart/src/main/java/net/minidev/json/parser/JSONParserReader.java b/json-smart/src/main/java/net/minidev/json/parser/JSONParserReader.java index 2b42662..e8841c4 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/JSONParserReader.java +++ b/json-smart/src/main/java/net/minidev/json/parser/JSONParserReader.java @@ -26,7 +26,7 @@ /** * Parser for JSON text. Please note that JSONParser is NOT thread-safe. * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ class JSONParserReader extends JSONParserStream { private Reader in; diff --git a/json-smart/src/main/java/net/minidev/json/parser/JSONParserStream.java b/json-smart/src/main/java/net/minidev/json/parser/JSONParserStream.java index 09234dd..05ec287 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/JSONParserStream.java +++ b/json-smart/src/main/java/net/minidev/json/parser/JSONParserStream.java @@ -23,7 +23,7 @@ /** * Parser for JSON text. Please note that JSONParser is NOT thread-safe. * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> * @see JSONParserInputStream * @see JSONParserReader */ diff --git a/json-smart/src/main/java/net/minidev/json/parser/JSONParserString.java b/json-smart/src/main/java/net/minidev/json/parser/JSONParserString.java index eef4da2..94f71a8 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/JSONParserString.java +++ b/json-smart/src/main/java/net/minidev/json/parser/JSONParserString.java @@ -22,7 +22,7 @@ /** * Parser for JSON text. Please note that JSONParser is NOT thread-safe. * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ class JSONParserString extends JSONParserMemory { private String in; @@ -63,8 +63,13 @@ protected void extractString(int beginIndex, int endIndex) { } protected void extractStringTrim(int start, int stop) { + while (start < stop-1 && Character.isWhitespace(in.charAt(start))) { + start++; + } + while (stop-1 > start && Character.isWhitespace(in.charAt(stop-1))) { + stop--; + } extractString(start, stop); - xs = xs.trim(); } protected int indexOf(char c, int pos) { diff --git a/json-smart/src/main/java/net/minidev/json/parser/ParseException.java b/json-smart/src/main/java/net/minidev/json/parser/ParseException.java index e652cf2..e9332d9 100644 --- a/json-smart/src/main/java/net/minidev/json/parser/ParseException.java +++ b/json-smart/src/main/java/net/minidev/json/parser/ParseException.java @@ -18,7 +18,7 @@ /** * ParseException explains why and where the error occurs in source JSON text. * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> */ public class ParseException extends Exception { private static final long serialVersionUID = 8879024178584091857L; diff --git a/json-smart/src/main/java/net/minidev/json/writer/JsonReaderI.java b/json-smart/src/main/java/net/minidev/json/writer/JsonReaderI.java index 1cbd2d3..db54df7 100644 --- a/json-smart/src/main/java/net/minidev/json/writer/JsonReaderI.java +++ b/json-smart/src/main/java/net/minidev/json/writer/JsonReaderI.java @@ -101,7 +101,7 @@ public Object createArray() { /** * Allow a mapper to converte a temprary structure to the final data format. * - * example: convert an List to an int[] + * example: convert an List<Integer> to an int[] */ @SuppressWarnings("unchecked") public T convert(Object current) { diff --git a/json-smart/src/main/java/net/minidev/json/writer/UpdaterMapper.java b/json-smart/src/main/java/net/minidev/json/writer/UpdaterMapper.java index 5d6954a..8c8cd2f 100644 --- a/json-smart/src/main/java/net/minidev/json/writer/UpdaterMapper.java +++ b/json-smart/src/main/java/net/minidev/json/writer/UpdaterMapper.java @@ -83,7 +83,7 @@ public Object createArray() { /** * Allow a mapper to converte a temprary structure to the final data format. * - * example: convert an List to an int[] + * example: convert an List<Integer> to an int[] */ @SuppressWarnings("unchecked") public T convert(Object current) { diff --git a/json-smart/src/test/java/net/minidev/json/test/MustThrows.java b/json-smart/src/test/java/net/minidev/json/test/MustThrows.java index d3d42d7..f013561 100644 --- a/json-smart/src/test/java/net/minidev/json/test/MustThrows.java +++ b/json-smart/src/test/java/net/minidev/json/test/MustThrows.java @@ -8,7 +8,6 @@ public class MustThrows { public static void testStrictInvalidJson(String json, int execptionType) throws Exception { testStrictInvalidJson(json, execptionType, null); - } public static void testStrictInvalidJson(String json, int execptionType, Class cls) throws Exception { diff --git a/json-smart/src/test/java/net/minidev/json/test/TestCompressorFlags.java b/json-smart/src/test/java/net/minidev/json/test/TestCompressorFlags.java index 74f2669..d8909c7 100644 --- a/json-smart/src/test/java/net/minidev/json/test/TestCompressorFlags.java +++ b/json-smart/src/test/java/net/minidev/json/test/TestCompressorFlags.java @@ -8,7 +8,7 @@ /** * Test all Compression Styles * - * @author Uriel Chemouni + * @author Uriel Chemouni <uchemouni@gmail.com> * */ public class TestCompressorFlags extends TestCase { diff --git a/json-smart/src/test/java/net/minidev/json/test/TestNavi.java b/json-smart/src/test/java/net/minidev/json/test/TestNavi.java index 6460730..53ebddb 100644 --- a/json-smart/src/test/java/net/minidev/json/test/TestNavi.java +++ b/json-smart/src/test/java/net/minidev/json/test/TestNavi.java @@ -44,7 +44,7 @@ public void testNaviWriteArray() { JSONNavi nav = JSONNavi.newInstance(); nav.set("type", "bundle").at("data").array().at(0).set("type", "object").set("name", "obj1").up().at(1).set("type", "object").set("name", "obj2").root(); String s2 = nav.toString(); - assertEquals(expected, nav.toString()); + assertEquals(expected, s2); nav = JSONNavi.newInstance(); nav.set("type", "bundle").at("data").array().atNext().set("type", "object").set("name", "obj1").up().atNext().set("type", "object").set("name", "obj2").root(); diff --git a/json-smart/src/test/java/net/minidev/json/test/strict/TestSpecialChar.java b/json-smart/src/test/java/net/minidev/json/test/strict/TestSpecialChar.java index 78e84d7..d6dadd0 100644 --- a/json-smart/src/test/java/net/minidev/json/test/strict/TestSpecialChar.java +++ b/json-smart/src/test/java/net/minidev/json/test/strict/TestSpecialChar.java @@ -1,6 +1,7 @@ package net.minidev.json.test.strict; import junit.framework.TestCase; +import net.minidev.json.JSONArray; import net.minidev.json.parser.JSONParser; import net.minidev.json.parser.ParseException; import net.minidev.json.test.MustThrows; @@ -13,8 +14,12 @@ public class TestSpecialChar extends TestCase { public void testSpecial127() throws Exception { + String s127 = String.format("%c", 127); String s = String.format("[\"%c\"]", 127); MustThrows.testInvalidJson(s, JSONParser.MODE_STRICTEST, ParseException.ERROR_UNEXPECTED_CHAR); + + JSONArray o = (JSONArray) new JSONParser(JSONParser.MODE_RFC4627).parse(s); + assertEquals(o.get(0), s127); } public void testSpecial31() throws Exception {