mirror of
https://github.com/fangyidong/json-simple.git
synced 2025-12-06 23:40:52 +03:00
Added a test case to cover https://code.google.com/p/json-simple/issues/detail?id=87.
This commit is contained in:
@@ -230,4 +230,27 @@ public class JSONValueTest extends TestCase {
|
|||||||
JSONValue.writeJSONString(new Object[] { "Hello", new Integer(12), new int[] { 1, 2, 3} }, writer);
|
JSONValue.writeJSONString(new Object[] { "Hello", new Integer(12), new int[] { 1, 2, 3} }, writer);
|
||||||
assertEquals("[\"Hello\",12,[1,2,3]]", writer.toString());
|
assertEquals("[\"Hello\",12,[1,2,3]]", writer.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testArraysOfArrays() throws IOException {
|
||||||
|
|
||||||
|
StringWriter writer;
|
||||||
|
|
||||||
|
final int[][][] nestedIntArray = new int[][][]{{{1}, {5}}, {{2}, {6}}};
|
||||||
|
final String expectedNestedIntString = "[[[1],[5]],[[2],[6]]]";
|
||||||
|
|
||||||
|
assertEquals(expectedNestedIntString, JSONValue.toJSONString(nestedIntArray));
|
||||||
|
|
||||||
|
writer = new StringWriter();
|
||||||
|
JSONValue.writeJSONString(nestedIntArray, writer);
|
||||||
|
assertEquals(expectedNestedIntString, writer.toString());
|
||||||
|
|
||||||
|
final String[][] nestedStringArray = new String[][]{{"a", "b"}, {"c", "d"}};
|
||||||
|
final String expectedNestedStringString = "[[\"a\",\"b\"],[\"c\",\"d\"]]";
|
||||||
|
|
||||||
|
assertEquals(expectedNestedStringString, JSONValue.toJSONString(nestedStringArray));
|
||||||
|
|
||||||
|
writer = new StringWriter();
|
||||||
|
JSONValue.writeJSONString(nestedStringArray, writer);
|
||||||
|
assertEquals(expectedNestedStringString, writer.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user