File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed
main/java/club/someoneice/json/processor
test/java/club/someoneice/test Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ plugins {
1111}
1212
1313group ' club.someoneice.json'
14- version ' 1.7.4 '
14+ version ' 1.7.5 '
1515
1616repositories {
1717 mavenLocal()
Original file line number Diff line number Diff line change @@ -47,9 +47,29 @@ public static String asString(JsonNode<?> node) {
4747 public static String prettyPrint (String node , int ct ) {
4848 StringBuilder builder = new StringBuilder ();
4949 int count = ct ;
50+
51+ boolean rawInput = false ;
52+ boolean skinNext = false ;
53+
5054 char [] charList = node .toCharArray ();
5155 for (int i = 0 ; i < count ; i ++) builder .append (JsonParser .SP );
5256 for (char c : charList ) {
57+ if (skinNext ) {
58+ builder .append (c );
59+ skinNext = false ;
60+ continue ;
61+ }
62+
63+ if (c == JsonParser .KEY_STRING ) {
64+ rawInput = !rawInput ;
65+ }
66+
67+ if (rawInput ) {
68+ skinNext = c == '\\' ;
69+ builder .append (c );
70+ continue ;
71+ }
72+
5373 count = checkAndPut (builder , count , c );
5474 }
5575
Original file line number Diff line number Diff line change @@ -10,10 +10,10 @@ public static void main(String[] args) {
1010 MapNode map = new MapNode ();
1111
1212 ArrayNode node = new ArrayNode ();
13- node .add (new StringNode ("test" ));
13+ node .add (new StringNode ("\" test:test \" " ));
1414
1515 map .put ("array" , node );
16- map .put ("test" , new StringNode ("test" ));
16+ map .put ("test" , new StringNode ("test:test " ));
1717
1818 String out = JsonBuilder .prettyPrint (map );
1919 System .out .println (out );
You can’t perform that action at this time.
0 commit comments