Skip to content

Commit b34bcc3

Browse files
committed
wip on json resourcefix
1 parent 786eea8 commit b34bcc3

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

gp-res-filter/src/main/java/com/ibm/g11n/pipeline/resfilter/impl/JsonResource.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
*/
5555
public class JsonResource extends ResourceFilter {
5656

57-
private class KeyPiece {
57+
static class KeyPiece {
5858
String keyValue;
5959
JsonToken keyType;
6060

@@ -248,19 +248,21 @@ public void write(OutputStream outStream, LanguageBundle languageBundle,
248248
}
249249
}
250250

251-
private List<KeyPiece> splitKeyPieces(String key) {
251+
static List<KeyPiece> splitKeyPieces(String key) {
252252
if (USE_JSONPATH_PATTERN.matcher(key).matches()) {
253253
List<KeyPiece> result = new ArrayList<KeyPiece>();
254-
Matcher onlyDigits = Pattern.compile("^\\d+$").matcher("");
254+
Matcher onlyDigits = Pattern.compile("^\\d+$").matcher("");
255255
// Disregard $ at the beginning - it's not really part of the key...
256256
List<String> tokens = findTokens(key.substring(JSONPATH_ROOT.length()));
257257
for (String s : tokens) {
258258
if (s.startsWith("'")) {
259259
// Turn any "\u0027" in the key back into '
260260
String modifiedKeyPiece = s.substring(1, s.length() - 1).replaceAll("\\\\u0027", "'");
261261
result.add(new KeyPiece(modifiedKeyPiece, JsonToken.BEGIN_OBJECT));
262-
} else if (onlyDigits.reset(s).matches()) {
262+
} else if (onlyDigits.reset(s).matches()) { // BAD
263263
result.add(new KeyPiece(s, JsonToken.BEGIN_ARRAY));
264+
} else if (false && s.startsWith("[") && (s.length() > 1)) {
265+
result.add(new KeyPiece(s.substring(1, s.length() - 1), JsonToken.BEGIN_ARRAY));
264266
} else {
265267
for (String s2 : s.split("\\.")) {
266268
if (!s2.isEmpty()) {
@@ -275,7 +277,7 @@ private List<KeyPiece> splitKeyPieces(String key) {
275277
return Collections.singletonList(new KeyPiece(key, JsonToken.BEGIN_OBJECT));
276278
}
277279

278-
private static List<String> findTokens(String data) {
280+
static List<String> findTokens(String data) {
279281
List<String> tokens = new ArrayList<String>();
280282
boolean inQuotes = false;
281283
StringBuilder currentToken = new StringBuilder();
@@ -286,10 +288,16 @@ private static List<String> findTokens(String data) {
286288
inQuotes = !inQuotes;
287289
}
288290
if (!inQuotes && (c == '.' || c == '[' || c == ']')) {
291+
// if (c == ']') {
292+
// currentToken.append(c);
293+
// }
289294
if (currentToken.length() > 0) {
290295
tokens.add(currentToken.toString());
291296
currentToken.setLength(0);
292297
}
298+
// if (c == '[') {
299+
// currentToken.append(c);
300+
// }
293301
} else {
294302
currentToken.append(c);
295303
}

0 commit comments

Comments
 (0)