Skip to content

Commit

Permalink
bug fixed for jsonpath. issue #735
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jul 22, 2016
1 parent aa203af commit 6a4e825
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/alibaba/fastjson/JSONPath.java
Expand Up @@ -939,7 +939,8 @@ Segement parseArrayAccess(boolean acceptBracket) {
String text = path.substring(start, end);

if (text.indexOf("\\.") != -1) {
return new PropertySegement(text, false);
String propName = text.replaceAll("\\\\\\.","\\.");
return new PropertySegement(propName, false);
}

Segement segment = buildArraySegement(text);
Expand Down
4 changes: 3 additions & 1 deletion src/test/java/com/alibaba/json/bvt/path/JSONPath_4.java
@@ -1,5 +1,7 @@
package com.alibaba.json.bvt.path;

import org.junit.Assert;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONPath;

Expand All @@ -10,8 +12,8 @@ public class JSONPath_4 extends TestCase {
public void test_path() throws Exception {
String a = "{\"key\":\"value\",\"10.0.1.1\":\"haha\"}";
Object x = JSON.parse(a);
System.out.println(JSON.toJSONString(x));
JSONPath.set(x, "$.test", "abc");
Object o = JSONPath.eval(x, "$.10\\.0\\.1\\.1");
Assert.assertEquals("haha", o);
}
}

0 comments on commit 6a4e825

Please sign in to comment.