circular-reference

How to restore circular references (e.g. “$id”) from Json.NET-serialized JSON?

假装没事ソ 提交于 2019-11-26 12:47:37
问题 Is there an existing javascript library which will deserialize Json.Net with reference loop handling? { \"$id\": \"1\", \"AppViewColumns\": [ { \"$id\": \"2\", \"AppView\": {\"$ref\":\"1\"}, \"ColumnID\": 1, } ] } this should deserialize to an object with a reference loop between the object in the array and the outer object 回答1: The answers given almost worked for me, but the latest version of MVC, JSON.Net, and DNX uses "$ref" and "$id", and they may be out of order. So I've modified

Circular reference causing stack overflow with Automapper

China☆狼群 提交于 2019-11-26 11:25:55
问题 I\'m using Automapper to map my NHibernate proxy objects (DTO) to my CSLA business objects I\'m using Fluent NHibernate to create the mappings - this is working fine The problem I have is that the Order has a collection of OrderLines and each of these has a reference to Order . public class OrderMapping : ClassMap<OrderDTO> { public OrderMapping() { // Standard properties Id(x => x.OrderId); Map(x => x.OrderDate); Map(x => x.Address); HasMany<OrderLineDTO>(x => x.OrderLines).KeyColumn(\

How to serialize DOM node to JSON even if there are circular references?

核能气质少年 提交于 2019-11-26 10:28:09
I want to serialize DOM node or even whole window to JSON. For example: >> serialize(document) -> { "URL": "http://stackoverflow.com/posts/2303713", "body": { "aLink": "", "attributes": [ "getNamedItem": "function getNamedItem() { [native code] }", ... ], ... "ownerDocument": "#" // recursive link here }, ... } JSON.stringify() JSON.stringify(window) // TypeError: Converting circular structure to JSON The problem is JSON does not support circular references by default. var obj = {} obj.me = obj JSON.stringify(obj) // TypeError: Converting circular structure to JSON window and DOM nodes have

What lifetimes do I use to create Rust structs that reference each other cyclically?

本秂侑毒 提交于 2019-11-26 09:51:09
问题 I\'d like to have struct members that know their parent. This is approximately what I\'m trying to do: struct Parent<\'me> { children: Vec<Child<\'me>>, } struct Child<\'me> { parent: &\'me Parent<\'me>, i: i32, } fn main() { let mut p = Parent { children: vec![] }; let c1 = Child { parent: &p, i: 1 }; p.children.push(c1); } I tried to appease the compiler with lifetimes without completely understanding what I was doing. Here\'s the error message I\'m stuck on: error[E0502]: cannot borrow `p

Json and Java - Circular Reference

五迷三道 提交于 2019-11-26 09:42:52
问题 I\'m having and issue with the Circular reference. I have Rest Webservices which returns objects to the front end, the issue is when I try to return objects that have several references so as the result I get an infinite response, which generate java.lang.IllegalStateException: Cannot call sendError() after the response has been committed The objects are generated automatically by Hibernate Code Generation and I need to have the circular reference in the backend, I\'ve just need to remove it

How to serialize DOM node to JSON even if there are circular references?

拟墨画扇 提交于 2019-11-26 08:50:53
问题 I want to serialize DOM node or even whole window to JSON. For example: >> serialize(document) -> { \"URL\": \"http://stackoverflow.com/posts/2303713\", \"body\": { \"aLink\": \"\", \"attributes\": [ \"getNamedItem\": \"function getNamedItem() { [native code] }\", ... ], ... \"ownerDocument\": \"#\" // recursive link here }, ... } JSON.stringify() JSON.stringify(window) // TypeError: Converting circular structure to JSON The problem is JSON does not support circular references by default. var

Circular references in Javascript / Garbage collector

邮差的信 提交于 2019-11-26 06:37:12
问题 Can somebody explain in detail how Javascript engines deal with circular references ? Is there a big difference between browsers or even node.js ? What I\'m talking about is an explicit back-/next reference within objects. For instance: var objA = { prop: \"foo\", next: null }; var objB = { prop: \"foo\", prev: null }; objA.next = objB; objB.prev = objA; There we go. If we do a console.log( objA ) we can see that we created an infinite chain. The big question is, is this bad ? Does it create

Garbage collector and circular reference

北城以北 提交于 2019-11-26 05:58:26
问题 Consider these two classes: public class A { B b; public A(B b) { this.b = b; } } public class B { A a; public B() { this.a = new A(this); } } If I have classes designed like above, would the objects of such classes be collected by Garbage Collector (GC)? Suppose I do this: void f() { B b = new B(); } In this method, I create an instance of B called b , and when the method returns, b goes out of scope, and the GC should be able to collect it, but if it were to collect it, it would have to

How to avoid the “Circular view path” exception with Spring MVC test

China☆狼群 提交于 2019-11-26 05:53:23
问题 I have the following code in one of my controllers: @Controller @RequestMapping(\"/preference\") public class PreferenceController { @RequestMapping(method = RequestMethod.GET, produces = \"text/html\") public String preference() { return \"preference\"; } } I am simply trying to test it using Spring MVC test as follows: @ContextConfiguration @WebAppConfiguration @RunWith(SpringJUnit4ClassRunner.class) public class PreferenceControllerTest { @Autowired private WebApplicationContext ctx;

How did Microsoft create assemblies that have circular references?

混江龙づ霸主 提交于 2019-11-26 05:17:38
问题 In the .NET BCL there are circular references between: System.dll and System.Xml.dll System.dll and System.Configuration.dll System.Xml.dll and System.Configuration.dll Here\'s a screenshot from .NET Reflector that shows what I mean: How Microsoft created these assemblies is a mystery to me. Is a special compilation process required to allow this? I imagine something interesting is going on here. 回答1: I can only tell how the Mono Project does this. The theorem is quite simple, though it gives