Giter Site home page Giter Site logo

Comments (9)

wenshao avatar wenshao commented on May 3, 2024

循环引用和重复引用这两个目前没有区别对待的,而且还没有方案

from fastjson.

ptma avatar ptma commented on May 3, 2024

我有一个方案,不需要改动很多代码,直接使用现有的 SerialContext ,判断是否递归引用时只要递归检查parent 里面的 object 是否是本身;

上述方案我已有实现,但是不知道是不是我代码没看透,貌似 ListSerializer 里 85、86两行代码是多余的(会导致多出一个层级关系)
itemSerializer = serializer.getObjectWriter(item.getClass());
//SerialContext itemContext = new SerialContext(context, object, fieldName);
//serializer.setContext(itemContext);
itemSerializer.write(serializer, item, i, elementType);

from fastjson.

wenshao avatar wenshao commented on May 3, 2024

A -> B -> C -> B -> A这种如何检测?

from fastjson.

ptma avatar ptma commented on May 3, 2024

在这个分支中 write 第二个B 时,可以在 B 的 Context 的 parent 链中找到第一个B是等于本身的,这是就该输出为引用了。

你举得这个例子还会有一个
A -> B -> A 也是递归引用了

from fastjson.

wenshao avatar wenshao commented on May 3, 2024

A -> B -> C -> A这种呢?

from fastjson.

ptma avatar ptma commented on May 3, 2024

A -> B -> C -> A 这种情况 write 第二个 A 时输出为引用;

我已通过邮件发了部分修改过的代码到你的邮箱

from fastjson.

wenshao avatar wenshao commented on May 3, 2024

你可以通过github的pull request提交patch么?

from fastjson.

wenshao avatar wenshao commented on May 3, 2024

由于新开了issue,旧这个关闭。

from fastjson.

olddoor avatar olddoor commented on May 3, 2024

soga.源码看不太懂. 原来是用DisableCircularReferenceDetect 来解决.

from fastjson.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.