Skip to content

Commit 45b1843

Browse files
author
Antonio Sanchez
committed
Removed unnecessary escape of forward slash
1 parent e26b25e commit 45b1843

File tree

4 files changed

+15
-9
lines changed

4 files changed

+15
-9
lines changed

src/main/java/org/json/simple/JSONObject.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public static String toString(String key,Object value){
122122
}
123123

124124
/**
125-
* Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).
125+
* Escape quotes, \, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).
126126
* It's the same as JSONValue.escape() only for compatibility here.
127127
*
128128
* @see org.json.simple.JSONValue#escape(String)

src/main/java/org/json/simple/JSONValue.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public static String toJSONString(Object value){
251251
}
252252

253253
/**
254-
* Escape quotes, \, /, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).
254+
* Escape quotes, \, \r, \n, \b, \f, \t and other control characters (U+0000 through U+001F).
255255
* @param s
256256
* @return
257257
*/
@@ -293,9 +293,6 @@ static void escape(String s, StringBuffer sb) {
293293
case '\t':
294294
sb.append("\\t");
295295
break;
296-
case '/':
297-
sb.append("\\/");
298-
break;
299296
default:
300297
//Reference: http://www.unicode.org/versions/Unicode5.1.0/
301298
if((ch>='\u0000' && ch<='\u001F') || (ch>='\u007F' && ch<='\u009F') || (ch>='\u2000' && ch<='\u20FF')){

src/test/java/org/json/simple/JSONEmptyAndNullTest.java

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
package org.json.simple;
22

3-
import org.json.simple.JSONArray;
4-
import org.json.simple.JSONObject;
53
import org.json.simple.parser.JSONParser;
64
import org.json.simple.parser.ParseException;
7-
85
import org.junit.Assert;
9-
import org.junit.Test;
6+
107
import junit.framework.TestCase;
118

129
public class JSONEmptyAndNullTest extends TestCase {

src/test/java/org/json/simple/JSONValueTest.java

+12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
import java.io.IOException;
44
import java.io.StringWriter;
55

6+
import org.json.simple.parser.JSONParser;
7+
import org.json.simple.parser.ParseException;
8+
69
import junit.framework.TestCase;
710

811
public class JSONValueTest extends TestCase {
@@ -253,4 +256,13 @@ public void testArraysOfArrays() throws IOException {
253256
JSONValue.writeJSONString(nestedStringArray, writer);
254257
assertEquals(expectedNestedStringString, writer.toString());
255258
}
259+
260+
public void testUrl() throws ParseException {
261+
String jsonString = "{\"url\": \"http://www.testthis.com/hello/world/slash.html\"}";
262+
JSONObject jobj = new JSONObject();
263+
jobj.put("url", "http://www.testthis.com/hello/world/slash.html");
264+
JSONParser parser = new JSONParser();
265+
Object obj = parser.parse(jsonString);
266+
assertEquals(jobj, obj);
267+
}
256268
}

0 commit comments

Comments
 (0)