Skip to content

Commit

Permalink
fix: support of JSONObject in serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
lvca committed Apr 29, 2024
1 parent 0a5f381 commit d7b869a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import com.arcadedb.log.LogManager;
import com.arcadedb.query.sql.executor.Result;
import com.arcadedb.schema.DocumentType;
import com.arcadedb.serializer.json.JSONObject;
import com.arcadedb.utility.DateUtils;

import java.lang.reflect.*;
Expand Down Expand Up @@ -461,6 +462,9 @@ else if (value instanceof LocalDate)
case BinaryTypes.TYPE_MAP: {
final Dictionary dictionary = database.getSchema().getDictionary();

if( value instanceof JSONObject)
value = ((JSONObject) value).toMap();

final Map<Object, Object> map = (Map<Object, Object>) value;
content.putUnsignedNumber(map.size());
for (final Map.Entry<Object, Object> entry : map.entrySet()) {
Expand Down
11 changes: 6 additions & 5 deletions engine/src/main/java/com/arcadedb/serializer/BinaryTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.arcadedb.database.Document;
import com.arcadedb.database.RID;
import com.arcadedb.query.sql.executor.Result;
import com.arcadedb.serializer.json.JSONObject;
import com.arcadedb.utility.DateUtils;

import java.lang.reflect.*;
Expand Down Expand Up @@ -53,12 +54,12 @@ public class BinaryTypes {
public final static byte TYPE_EMBEDDED = 19;
public final static byte TYPE_DATETIME_MICROS = 20; // @SINCE 23.1.1
public final static byte TYPE_DATETIME_NANOS = 21; // @SINCE 23.1.1
public final static byte TYPE_DATETIME_SECOND = 22; // @SINCE 23.1.1
public final static byte TYPE_DATETIME_SECOND = 22; // @SINCE 23.1.1
public final static byte TYPE_ARRAY_OF_SHORTS = 23; // @SINCE 23.6.1
public final static byte TYPE_ARRAY_OF_INTEGERS = 24; // @SINCE 23.6.1
public final static byte TYPE_ARRAY_OF_LONGS = 25; // @SINCE 23.6.1
public final static byte TYPE_ARRAY_OF_FLOATS = 26; // @SINCE 23.6.1
public final static byte TYPE_ARRAY_OF_DOUBLES = 27; // @SINCE 23.6.1
public final static byte TYPE_ARRAY_OF_LONGS = 25; // @SINCE 23.6.1
public final static byte TYPE_ARRAY_OF_FLOATS = 26; // @SINCE 23.6.1
public final static byte TYPE_ARRAY_OF_DOUBLES = 27; // @SINCE 23.6.1

public static byte getTypeFromValue(final Object value) {
final byte type;
Expand Down Expand Up @@ -102,7 +103,7 @@ else if (value instanceof byte[])
type = TYPE_BINARY;
else if (value instanceof UUID)
type = TYPE_UUID;
else if (value instanceof Map)
else if (value instanceof Map || value instanceof JSONObject)
type = TYPE_MAP;
else if (value instanceof Document)
type = ((Document) value).getIdentity() != null ? TYPE_RID : TYPE_EMBEDDED;
Expand Down

0 comments on commit d7b869a

Please sign in to comment.