Skip to content

Commit 378e6a1

Browse files
committed
v2.5.3
1 parent e3613e2 commit 378e6a1

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

ChangeLog.md

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a
66

77
## [Unreleased]
88

9+
## [2.5.3] - 2021-04-23
10+
11+
- improved performances of `VPackParser.toJson()`
912
- added `VPackSlice.getSchemaDescription()` to return a printable schema description of the VPack slice
1013

1114
## [2.5.2] - 2021-03-23

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
<groupId>com.arangodb</groupId>
66
<artifactId>velocypack</artifactId>
7-
<version>2.5.3-SNAPSHOT</version>
7+
<version>2.5.3</version>
88
<inceptionYear>2017</inceptionYear>
99
<packaging>jar</packaging>
1010

src/main/java/com/arangodb/velocypack/VPackParser.java

+10-10
Original file line numberDiff line numberDiff line change
@@ -280,19 +280,15 @@ private void parse(
280280
} else if (value.isBoolean()) {
281281
json.append(value.getAsBoolean());
282282
} else if (value.isString()) {
283-
json.append("\"");
284-
json.append(value.getAsString().replace("\"", "\\\""));
285-
json.append("\"");
283+
appendJsonString(json, value.getAsString());
286284
} else if (value.isDouble()) {
287285
json.append(value.getAsDouble());
288286
} else if (value.isInt()) {
289287
json.append(value.getAsLong());
290288
} else if (value.isNumber()) {
291289
json.append(value.getAsNumber());
292290
} else if (value.isDate()) {
293-
json.append("\"");
294-
json.append(DateUtil.format(value.getAsDate()).replace("\"", "\\\""));
295-
json.append("\"");
291+
appendJsonString(json, DateUtil.format(value.getAsDate()));
296292
} else if (value.isNull()) {
297293
json.append(NULL);
298294
} else {
@@ -302,10 +298,7 @@ private void parse(
302298
}
303299

304300
private static void appendField(final String attribute, final StringBuilder json) {
305-
json.append("\"");
306-
json.append(attribute.replace("\"", "\\\""));
307-
json.append("\"");
308-
json.append(FIELD);
301+
appendJsonString(json, attribute).append(FIELD);
309302
}
310303

311304
private void parseObject(final VPackSlice value, final StringBuilder json, final boolean includeNullValues)
@@ -458,6 +451,13 @@ private void parseValue(final VPackBuilder builder, final String fieldName, fina
458451
}
459452
}
460453

454+
private static StringBuilder appendJsonString(final StringBuilder json, final String text) {
455+
return json
456+
.append("\"")
457+
.append(text.replace("\"", "\\\""))
458+
.append("\"");
459+
}
460+
461461
public static String toJSONString(final String text) {
462462
final StringWriter writer = new StringWriter();
463463
try {

0 commit comments

Comments
 (0)