WebReflection/circular-json — 608★ trên GitHub (JavaScript). JSON does not handle circular references. Now it does
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
NOTE: Platforms without native JSON (i.e. MSIE <= 8) requires json3.js or similar.
It is also a bad idea to CircularJSON.parse(JSON.stringify(object)) because of those manipulation used in CircularJSON.stringify() able to make parsing safe and secure.
As summary: CircularJSON.parse(CircularJSON.stringify(object)) is the way to go, same is for JSON.parse(JSON.stringify(object)).
API
It's the same as native JSON, except the fourth parameter placeholder, which circular references to be replaced with "[Circular]" (i.e. for logging).
Bear in mind JSON.parse(CircularJSON.stringify(object)) will work but not produce the expected output.
Similar Libraries
Why Not the @izs One
The module json-stringify-safe seems to be for console.log() but it's completely pointless for JSON.parse(), being latter one unable to retrieve back the initial structure. Here an example:
// a logged object with circular references
{
"circularRef": "[Circular]",
"list": [
"[Circular]",
"[Circular]"
]
}
// what do we do with above output ?
Just type this in your node console: var o = {}; o.a = o; console.log(o);. The output will be { a: [Circular] } ... good, but that ain't really solving the problem.
However, if that's all you need, the function used to create that kind of output is probably faster than CircularJSON and surely fits in less lines of code.
Why Not {{put random name}} Solution
So here the thing: circular references can be wrong but, if there is a need for them, any attempt to ignore them or remove them can be considered just a failure.
Not because the method is bad or it's not working, simply because the circular info, the one we needed and used in the first place, is lost!
In this case, CircularJSON does even more than just solve circular and recursions: it maps all same objects so that less memory is used as well on deserialization as less bandwidth too!
It's able to redefine those references back later on so the way we store is the way we retrieve and in a reasonably performant way, also trusting the snappy and native JSON methods to iterate.
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/WebReflection/circular-json là nguồn chính thức.
WebReflection/circular-json có bao nhiêu sao?
WebReflection/circular-json có 608 sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/WebReflection/circular-json. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
WebReflection/circular-json có phải mã nguồn mở không?
Có — WebReflection/circular-json phát hành theo license MIT, nghĩa là mã nguồn mở để đọc, fork và (tùy license) tái sử dụng. Mã: github.com/WebReflection/circular-json.
WebReflection/circular-json còn đang phát triển không?
Commit gần nhất trên WebReflection/circular-json là 7.2 năm trước (theo timestamp GitHub). Repo có 79 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
WebReflection/circular-json là gì?
WebReflection/circular-json (WebReflection/circular-json) là dự án JavaScript trên GitHub. Theo mô tả gốc: JSON does not handle circular references. Now it does
Đọc đầy đủ README ở tab phía trên.
circular-json có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về circular-json.