From 4e3460e0cdaa1786275e80e0cfaa9e4cbf757892 Mon Sep 17 00:00:00 2001 From: kunfei Date: Sun, 17 May 2020 22:27:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/analyzeRule/AnalyzeByJSonPath.java | 29 +++++++++---------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/com/kunfei/bookshelf/model/analyzeRule/AnalyzeByJSonPath.java b/app/src/main/java/com/kunfei/bookshelf/model/analyzeRule/AnalyzeByJSonPath.java index c6680291fd..1d74223e43 100644 --- a/app/src/main/java/com/kunfei/bookshelf/model/analyzeRule/AnalyzeByJSonPath.java +++ b/app/src/main/java/com/kunfei/bookshelf/model/analyzeRule/AnalyzeByJSonPath.java @@ -47,24 +47,23 @@ public String getString(String rule) { } if (rules.length == 1) { - if (rule.startsWith("$.")) { - try { - Object object = ctx.read(rule); - if (object instanceof List) { - StringBuilder builder = new StringBuilder(); - for (Object o : (List) object) { - builder.append(o).append("\n"); - } - result = builder.toString().replaceAll("\\n$", ""); - } else { - result = String.valueOf(object); + try { + Object object = ctx.read(rule); + if (object instanceof List) { + StringBuilder builder = new StringBuilder(); + for (Object o : (List) object) { + builder.append(o).append("\n"); } - } catch (Exception ignored) { + result = builder.toString().replaceAll("\\n$", ""); + } else { + result = String.valueOf(object); + } + } catch (Exception e) { + if (!rule.startsWith("$.")) { + return rule; } - return result; - } else { - return rule; } + return result; } else { List textS = new ArrayList<>(); for (String rl : rules) {