From 74e8fd2fa8a13cc3e35ca25b31ce3ba3de8dd695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=AB=98=E9=93=81?= Date: Wed, 26 Aug 2015 13:17:01 +0800 Subject: [PATCH] bug fixed for jsonpath --- src/main/java/com/alibaba/fastjson/JSONPath.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/alibaba/fastjson/JSONPath.java b/src/main/java/com/alibaba/fastjson/JSONPath.java index c06a076cb..e40516257 100644 --- a/src/main/java/com/alibaba/fastjson/JSONPath.java +++ b/src/main/java/com/alibaba/fastjson/JSONPath.java @@ -318,6 +318,14 @@ public class JSONPath implements ObjectSerializer { } Segement readSegement() { + if (level == 0 && path.length() == 1) { + if (isDigitFirst(ch)) { + int index = ch - '0'; + return new ArrayAccessSegement(index); + } else if ((ch >= 'a' && ch <= 'z') || ((ch >= 'A' && ch <= 'Z'))) { + return new PropertySegement(Character.toString(ch)); + } + } while (!isEOF()) { skipWhitespace();