File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed
core/src/main/java/com/arangodb/internal/serde Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 6
6
import com .arangodb .internal .ArangoRequestParam ;
7
7
import com .arangodb .util .RawJson ;
8
8
import com .arangodb .internal .InternalRequest ;
9
+ import com .fasterxml .jackson .core .JsonFactory ;
9
10
import com .fasterxml .jackson .core .JsonGenerator ;
10
11
import com .fasterxml .jackson .core .JsonParser ;
11
12
import com .fasterxml .jackson .databind .JsonSerializer ;
12
13
import com .fasterxml .jackson .databind .SerializerProvider ;
13
14
14
15
import java .io .IOException ;
16
+ import java .nio .charset .StandardCharsets ;
15
17
import java .util .Collection ;
16
18
import java .util .HashMap ;
17
19
import java .util .Map ;
@@ -22,9 +24,13 @@ public final class InternalSerializers {
22
24
static final JsonSerializer <RawJson > RAW_JSON_SERIALIZER = new JsonSerializer <RawJson >() {
23
25
@ Override
24
26
public void serialize (RawJson value , JsonGenerator gen , SerializerProvider serializers ) throws IOException {
25
- try (JsonParser parser = SerdeUtils .INSTANCE .getJsonMapper ().createParser (value .get ())) {
26
- parser .nextToken ();
27
- gen .copyCurrentStructure (parser );
27
+ if (JsonFactory .FORMAT_NAME_JSON .equals (gen .getCodec ().getFactory ().getFormatName ())) {
28
+ gen .writeRawValue (new RawUserDataValue (value .get ().getBytes (StandardCharsets .UTF_8 )));
29
+ } else {
30
+ try (JsonParser parser = SerdeUtils .INSTANCE .getJsonMapper ().createParser (value .get ())) {
31
+ parser .nextToken ();
32
+ gen .copyCurrentStructure (parser );
33
+ }
28
34
}
29
35
}
30
36
};
Original file line number Diff line number Diff line change 5
5
import com .arangodb .entity .BaseEdgeDocument ;
6
6
import com .arangodb .util .RawBytes ;
7
7
import com .arangodb .util .RawJson ;
8
+ import com .fasterxml .jackson .core .JsonFactory ;
8
9
import com .fasterxml .jackson .core .JsonParser ;
9
10
import com .fasterxml .jackson .core .JsonProcessingException ;
10
11
import com .fasterxml .jackson .core .JsonToken ;
@@ -98,7 +99,6 @@ public String writeJson(final JsonNode data) {
98
99
* @param parser JsonParser with current token pointing to the node to extract
99
100
* @return byte array
100
101
*/
101
- // TODO: move to InternalSerdeImpl, non-static, keep reference to serde to check content-type
102
102
public static byte [] extractBytes (JsonParser parser ) throws IOException {
103
103
JsonToken t = parser .currentToken ();
104
104
if (t .isStructEnd () || t == JsonToken .FIELD_NAME ) {
@@ -119,7 +119,7 @@ public static byte[] extractBytes(JsonParser parser) throws IOException {
119
119
}
120
120
}
121
121
parser .finishToken ();
122
- if ("JSON" .equals (parser .getCodec ().getFactory ().getFormatName ())) {
122
+ if (JsonFactory . FORMAT_NAME_JSON .equals (parser .getCodec ().getFactory ().getFormatName ())) {
123
123
end = (int ) parser .currentLocation ().getByteOffset ();
124
124
}
125
125
return Arrays .copyOfRange (data , start , end );
You can’t perform that action at this time.
0 commit comments