Skip to content

[Java] Deserializing fastjson error #1170

@zhongchun

Description

@zhongchun

Describe the bug
Deserializing fastjson JSONObject error.

Expected behavior
It should deserialize to a JSONObject.

To Reproduce
fastjson version: 1.2.68.noneautotype
fury version: 0.3.1

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

import io.fury.Fury;
import io.fury.config.CompatibleMode;
import io.fury.config.Language;

public class SerializationUtilTest {

  @Test
  public void testEncodeDecode() {
    Fury fury =
        Fury.builder()
            .withLanguage(Language.JAVA)
            .withRefTracking(true)
            .requireClassRegistration(false)
            .withCompatibleMode(CompatibleMode.SCHEMA_CONSISTENT)
            .withCompatibleMode(CompatibleMode.COMPATIBLE)
            .withAsyncCompilation(true)
            .build();
    String json =
        "{\"vectors\":{\"dim128\":[{\"fieldNames\":[],\"opCode\":\"userDefine\",\"value\":[[0,1,2,3],[10,11,12,13],[20,21,22,23]],\"key\":\"sample_pic_vector\",\"version\":\"B1\"},{\"fieldNames\":[],\"opCode\":\"test_code\",\"value\":[[1,2,3,4,5],[11,12,13,14,15]],\"key\":\"test_key\",\"version\":\"B2\"}]}}";

    JSONObject jObj = (JSONObject) JSON.parse(json);
    JSONObject vectors = jObj.getJSONObject("vectors");

    byte[] data = fury.serialize(vectors);
    Object ret = fury.deserialize(data);
  }

}

Screenshots
image

Environment (please complete the following information):
Please specify the versions of Fury, OS, and others such as JDK/Python/Gcc/Clang/Go/NodeJS if they are used.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions