Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于重复依赖检测机制 #2240

Closed
liaowang11 opened this issue Jan 13, 2019 · 1 comment
Closed

关于重复依赖检测机制 #2240

liaowang11 opened this issue Jan 13, 2019 · 1 comment
Labels
Milestone

Comments

@liaowang11
Copy link

liaowang11 commented Jan 13, 2019

请问重复依赖检测机制是什么? 目前好像没有关闭重复依赖但是开启循环依赖的方法?
如下代码ResultList不会产生$ref, ResultMap会产生$ref.


    @Test
    public void testJSON() {
        ResultMap resultMap = new ResultMap();
        resultMap.setA(Collections.emptyMap());
        resultMap.setB(Collections.emptyMap());
        System.out.println(JSON.toJSONString(resultMap));

        ResultList resultList = new ResultList();
        resultList.setA(Collections.emptyList());
        resultList.setB(Collections.emptyList());
        System.out.println(JSON.toJSONString(resultList));
    }

    public static class ResultMap {
        private Map<Long, Integer> a;
        private Map<Long, Integer> b;

        public Map<Long, Integer> getA() {
            return a;
        }

        public void setA(Map<Long, Integer> a) {
            this.a = a;
        }

        public Map<Long, Integer> getB() {
            return b;
        }

        public void setB(Map<Long, Integer> b) {
            this.b = b;
        }
    }

    public static class ResultList {
        private List<Long> a;
        private List<Long> b;

        public List<Long> getA() {
            return a;
        }

        public void setA(List<Long> a) {
            this.a = a;
        }

        public List<Long> getB() {
            return b;
        }

        public void setB(List<Long> b) {
            this.b = b;
        }
    }

{"a":{},"b":{"$ref":"$.a"}}
{"a":[],"b":[]}
@wenshao wenshao added the bug label Jan 14, 2019
@wenshao wenshao added this to the 1.2.55 milestone Jan 14, 2019
@wenshao
Copy link
Member

wenshao commented Jan 20, 2019

问题已修复,请用新版本 https://github.com/alibaba/fastjson/releases/tag/1.2.55

@wenshao wenshao closed this as completed Jan 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants