NightJson: expand maps
This commit is contained in:
@@ -79,8 +79,9 @@ public class NightJson {
|
||||
while (it.hasNext()) {
|
||||
Object key = it.next();
|
||||
Object val = map.get(key);
|
||||
mapPairs.append("\n\t\t");
|
||||
mapPairs.append(String.format("%s: %s", objToString(key, key.getClass()), objToString(val, val.getClass())));
|
||||
mapPairs.append(it.hasNext() ? "," : "}");
|
||||
mapPairs.append(it.hasNext() ? "," : "\n\t}");
|
||||
}
|
||||
return mapPairs.toString();
|
||||
}
|
||||
@@ -153,9 +154,9 @@ public class NightJson {
|
||||
return jsonToMap(String.valueOf(submapString), k -> field.isPresent() ? getTypeArgument(field.get(), 1) : String.class);
|
||||
}
|
||||
else {
|
||||
if (val.startsWith(" ")) val = val.substring(1);
|
||||
while (val.startsWith(" ")) val = val.substring(1);
|
||||
val = val.replaceAll("[\"}\n]", "");
|
||||
if (val.endsWith(",")) val = val.substring(0, val.length() - 1);
|
||||
while (val.endsWith(",") || val.endsWith("\n") || val.endsWith("\t")) val = val.substring(0, val.length() - 1);
|
||||
|
||||
return stringToObj(val, keyToType.apply(key));
|
||||
}
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
{
|
||||
"scores": {"Martin": 6401}
|
||||
"scores": {
|
||||
"Marrrtin": 2648,
|
||||
"Marrtin": 623,
|
||||
"Martin": 147,
|
||||
"Mark": 84
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user