Untitled
unknown
plain_text
a year ago
548 B
5
Indexable
I have the following Java code that I use to parse JSON strings:
Pattern pa = Pattern.compile("\"([^\"]*?)\"\\s*:\\s*(\"[^\"]*?\"|\\d+|true|false|null|\\{.*?}|\\[.*?])");
Matcher ma = pa.matcher(json);
while (ma.find()) {
// Key
String fieldName = ma.group(1);
String fieldValue = !ma.group(2).startsWith("\"") ? ma.group(2) : ma.group(2).substring(1, ma.group(2).length() - 1);
This code works verz well except when I test it for using this string:
{"DoubleValue": 1.002}
it does not return 1.002, instead it returns 1
fix it!Editor is loading...
Leave a Comment