<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>.net Archives - Yumasoft</title>
	<atom:link href="https://blog.yumasoft.pl/tag/net/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.yumasoft.pl/tag/net/</link>
	<description>Software development blog</description>
	<lastBuildDate>Mon, 30 Aug 2021 04:02:53 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>https://blog.yumasoft.pl/wp-content/uploads/2021/05/cropped-yumasoft_icon_transparent-32x32.png</url>
	<title>.net Archives - Yumasoft</title>
	<link>https://blog.yumasoft.pl/tag/net/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Foreach, IEnumerable and IEnumerator in C#</title>
		<link>https://blog.yumasoft.pl/2021/09/foreach-ienumerable-and-ienumerator-in-c/</link>
					<comments>https://blog.yumasoft.pl/2021/09/foreach-ienumerable-and-ienumerator-in-c/#respond</comments>
		
		<dc:creator><![CDATA[Dawid Sibiński]]></dc:creator>
		<pubDate>Mon, 06 Sep 2021 06:00:00 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[.net framework]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[csharp]]></category>
		<category><![CDATA[dotnet]]></category>
		<guid isPermaLink="false">https://blog.yumasoft.pl/?p=593</guid>

					<description><![CDATA[<p>Today, we&#8217;re taking a deeper look at foreach loop in C#. What does a collection need to be able to use it in a foreach loop? Does it have to implement IEnumerable interface? These questions are often asked during interviews, so it&#8217;s worth knowing the answers ? We will go through a step-by-step example in&#8230;</p>
<p>The post <a rel="nofollow" href="https://blog.yumasoft.pl/2021/09/foreach-ienumerable-and-ienumerator-in-c/">Foreach, IEnumerable and IEnumerator in C#</a> appeared first on <a rel="nofollow" href="https://blog.yumasoft.pl">Yumasoft</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Today, we&#8217;re taking a deeper look at <code>foreach</code> loop in C#. What does a collection need to be able to use it in a <code>foreach</code> loop? Does it have to implement <code>IEnumerable</code> interface? These questions are often asked during interviews, so it&#8217;s worth knowing the answers ?</p>



<p>We will go through a step-by-step example in building our own custom collection to see how all that works. Let&#8217;s dive in! ?</p>



<span id="more-593"></span>



<p><em>Throughout this article, I&#8217;m working with a Unit Tests project using .NET 5, C# 9.0 and <a href="https://nunit.org/">NUnit</a>. It makes it easier to play with the code on your own. We can create our custom collection and at the same time try it out in a <code>foreach</code> loop in a test method. I recommend this approach for testing out various programming concepts for yourself ?</em></p>



<h2 class="wp-block-heading">Custom collection implementing IEnumerable&lt;T&gt;</h2>



<p>First, we want to implement our own, custom collection in C#. The most obvious solution is to implement <code>IEnumerable&lt;T></code> interface. Our IDE will require our class to implement <code>IEnumerator GetEnumerator()</code> and <code>IEnumerator IEnumerable.GetEnumerator()</code> methods, so let&#8217;s do that:</p>



<script src="https://gist.github.com/dsibinski/f40065534bf002dbdce0e834db636d3c.js"></script>



<p>Of course, this is just an example to satisfy the <code>foreach</code> loop, so we won&#8217;t care about the actual implementation of these methods ?</p>



<p>Custom collection implemented in such a way can be used in <code>foreach</code> loop: </p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img fetchpriority="high" decoding="async" width="444" height="266" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_ForeachIEnumerableCollection-1.png" alt="Custom collection used in a foreach loop (C#)" class="wp-image-599" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_ForeachIEnumerableCollection-1.png 444w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_ForeachIEnumerableCollection-1-300x180.png 300w" sizes="(max-width: 444px) 100vw, 444px" /></figure></div>



<h2 class="wp-block-heading">Does foreach require IEnumerable?</h2>



<p>Let&#8217;s try to get rid of implementing <code>IEnumerable</code> interface. As soon as we do it, our IDE complains:</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img decoding="async" width="856" height="394" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/2_IDEErrorIEnumerable.png" alt="Custom collection not implement IEnumerable and IDE complaining about &quot;IEnumerable.GetEnumerator&quot; method" class="wp-image-600" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/2_IDEErrorIEnumerable.png 856w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/2_IDEErrorIEnumerable-300x138.png 300w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/2_IDEErrorIEnumerable-768x353.png 768w" sizes="(max-width: 856px) 100vw, 856px" /></figure></div>



<p>Let&#8217;s try to remove <code>IEnumerable.GetEnumerator()</code> method completely, so our custom collection looks as follows:</p>



<script src="https://gist.github.com/dsibinski/af9b9f9b308e471652f2dcd754754bc6.js"></script>



<p>Now guess what &#8211; we can still use <code>MyCollection</code> within the <code>foreach</code> loop!</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img decoding="async" width="444" height="266" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/3_Foreach_Collection_with_GetEnumerator_method.png" alt="Custom collection used in a foreach loop (C#)" class="wp-image-601" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/3_Foreach_Collection_with_GetEnumerator_method.png 444w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/3_Foreach_Collection_with_GetEnumerator_method-300x180.png 300w" sizes="(max-width: 444px) 100vw, 444px" /></figure></div>



<p>So you already know that, when asked during an interview whether <code>foreach</code> needs a collection to implement <code>IEnumerable</code>, the answer is no ?</p>



<h2 class="wp-block-heading">Custom IEnumerator</h2>



<p>Currently, our collection has a single <code>GetEnumerator()</code> method returning <code>IEnumerator&lt;MyObject></code>. We already know that this method is needed in a collection to be able to use it within a <code>foreach</code> loop. </p>



<p>However, let&#8217;s work on what this method returns. We&#8217;ll implement our custom <code>IEnumerator</code>. Again &#8211; the most obvious solution is to create a class implementing <code>IEnumerator&lt;T></code> interface:</p>



<script src="https://gist.github.com/dsibinski/014116fc47bf9159dcfe3e44bb54b6fe.js"></script>



<p>That&#8217;s the implementation proposed by the IDE (Rider). We can now change our collection to use this custom enumerator. See that it can still be used within <code>foreach</code>:</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="467" height="466" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/4_Custom_Collection_With_Custom_Enumerator.png" alt="Custom collection (without implementing any interface) returns a custom enumerator MyObjectEnumerator" class="wp-image-603" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/4_Custom_Collection_With_Custom_Enumerator.png 467w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/4_Custom_Collection_With_Custom_Enumerator-300x300.png 300w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/4_Custom_Collection_With_Custom_Enumerator-150x150.png 150w" sizes="auto, (max-width: 467px) 100vw, 467px" /></figure></div>



<p>So far, so good. But why all these methods in <code>MyObjectEnumerator</code>? ?</p>



<h2 class="wp-block-heading">Does foreach need an enumerator implementing IEnumerator?</h2>



<p>If we remove inheritance from <code>IEnumerator</code> from <code>MyObjectEnumerator</code>, the IDE only complains about <code>IEnumerator.Current</code> property, so let&#8217;s get rid of it. Our custom enumerator now looks as follows:</p>



<script src="https://gist.github.com/dsibinski/bb9e8ef54834656d4994e337c00f6c8a.js"></script>



<p>Yeah, you guessed it again &#8211; we can still use our collection in a <code>foreach</code> loop ?</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="444" height="266" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/5_Foreach_custom_enumerator_no_interface.png" alt="Custom collection used in a foreach loop (C#)" class="wp-image-604" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/5_Foreach_custom_enumerator_no_interface.png 444w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/5_Foreach_custom_enumerator_no_interface-300x180.png 300w" sizes="auto, (max-width: 444px) 100vw, 444px" /></figure></div>



<p>However&#8230; Does our custom enumerator really needs all of these stuff:  <code>MoveNext(), Reset()</code>, <code>Dispose()</code> and <code>MyObject Current</code> ? Let&#8217;s remove all of them and see what our IDE tells us:</p>



<div class="wp-block-image"><figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="517" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/6_Foreach_empty_Enumerator_error-1024x517.png" alt="IDE (JetBrains Rider) error:
Type 'ForeachFun.MyCollection' cannot be used in 'foreach' statement because it neither implements 'IEnumerable' or 'IEnumerable', nor has suitable 'GetEnumerator' method which return type has 'Current' property and 'MoveNext' method" class="wp-image-605" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/6_Foreach_empty_Enumerator_error-1024x517.png 1024w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/6_Foreach_empty_Enumerator_error-300x151.png 300w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/6_Foreach_empty_Enumerator_error-768x388.png 768w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/6_Foreach_empty_Enumerator_error.png 1153w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure></div>



<p>That&#8217;s the error from IDE when trying to iterate through our custom collection in <code>foreach</code>:</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow"><p></p><cite>Type &#8216;ForeachFun.MyCollection&#8217; cannot be used in &#8216;foreach&#8217; statement because it neither implements &#8216;IEnumerable&#8217; or &#8216;IEnumerable&#8217;, <strong>nor has suitable &#8216;GetEnumerator&#8217; method which return type has &#8216;Current&#8217; property and &#8216;MoveNext&#8217; method</strong></cite></blockquote>



<p>This error actually tells us everything. This is the ultimate answer to the legendary C# interview question: &#8220;What does a collection need to be able to use it in <code>foreach</code> loop?&#8221;. In other words: &#8220;Is it necessary for a collection to implement <code>IEnumerable</code> to use it in a <code>foreach</code> loop?&#8221;</p>



<p>The answer is:<strong> a collection needs to have a <code>GetEnumerator</code>() method returning an object of type having <code>Current</code> property and <code>bool MoveNext()</code> method. No interfaces are required anywhere here ?</strong></p>



<p>The compiler uses duck typing to find these two necessary ingredients of the type returned from <code>GetEnumerator()</code>. It means that is looks for these properties by text. Later, depending on the type of <code>Current</code> property, a single element inside the <code>foreach</code> is typed accordingly. Only if this duck searching fails, the compiler checks whether the collection implements the interfaces.</p>



<p>In the end, this is our simplest and fully legit code (except the actual implementations of the methods, which is out of scope of this article):</p>



<script src="https://gist.github.com/dsibinski/99a2559ef72c2f493a231dc13879b4ec.js"></script>



<h2 class="wp-block-heading">Summary</h2>



<p>I hope you got to know something new about <code>foreach</code> loop from this article. This may not sound like a knowledge you&#8217;d need on a daily basis, but it&#8217;s worth knowing how stuff works under the hood ? Plus, you can always score a point during your next interview ?!</p>
<p>The post <a rel="nofollow" href="https://blog.yumasoft.pl/2021/09/foreach-ienumerable-and-ienumerator-in-c/">Foreach, IEnumerable and IEnumerator in C#</a> appeared first on <a rel="nofollow" href="https://blog.yumasoft.pl">Yumasoft</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.yumasoft.pl/2021/09/foreach-ienumerable-and-ienumerator-in-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How To Fix JSON.NET Circular References ($ref) In JavaScript</title>
		<link>https://blog.yumasoft.pl/2021/08/how-to-fix-json-net-circular-references-ref-in-javascript/</link>
					<comments>https://blog.yumasoft.pl/2021/08/how-to-fix-json-net-circular-references-ref-in-javascript/#respond</comments>
		
		<dc:creator><![CDATA[Dawid Sibiński]]></dc:creator>
		<pubDate>Sun, 15 Aug 2021 07:30:27 +0000</pubDate>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[json.net]]></category>
		<category><![CDATA[typescript]]></category>
		<guid isPermaLink="false">https://blog.yumasoft.pl/?p=518</guid>

					<description><![CDATA[<p>If you work with a .NET backend that uses JSON.NET for serialization, you might encounter such weird things in the JSON result returned from a controller: But what you actually want is the real object present there: After reading this article, you will know how to achieve that ? JSON.NET circular references are the issue&#8230;</p>
<p>The post <a rel="nofollow" href="https://blog.yumasoft.pl/2021/08/how-to-fix-json-net-circular-references-ref-in-javascript/">How To Fix JSON.NET Circular References ($ref) In JavaScript</a> appeared first on <a rel="nofollow" href="https://blog.yumasoft.pl">Yumasoft</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>If you work with a .NET backend that uses <a href="https://www.newtonsoft.com/json">JSON.NET</a> for serialization, you might encounter such weird things in the JSON result returned from a controller:</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="373" height="311" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_CircularReferenceExample.png" alt="JSON result from ASP.NET controller with $ref: &quot;1&quot; instead of a real object. Example of JSON.NET circular references" class="wp-image-519" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_CircularReferenceExample.png 373w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_CircularReferenceExample-300x250.png 300w" sizes="auto, (max-width: 373px) 100vw, 373px" /></figure></div>



<p>But what you actually want is the real object present there:</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="560" height="323" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/3_CurcularReferencesRemoved-1.png" alt="JSON result from ASP.NET controller with $ref: &quot;1&quot; replaced with a real object's content" class="wp-image-535" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/3_CurcularReferencesRemoved-1.png 560w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/3_CurcularReferencesRemoved-1-300x173.png 300w" sizes="auto, (max-width: 560px) 100vw, 560px" /></figure></div>



<p>After reading this article, you will know how to achieve that ?</p>



<span id="more-518"></span>



<h2 class="wp-block-heading">JSON.NET circular references are the issue</h2>



<p>Let&#8217;s take a look at our problematic JSON response object once again:</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="373" height="311" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_CircularReferenceExample.png" alt="JSON result from ASP.NET controller with $ref: &quot;1&quot; instead of a real object" class="wp-image-519" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_CircularReferenceExample.png 373w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_CircularReferenceExample-300x250.png 300w" sizes="auto, (max-width: 373px) 100vw, 373px" /></figure></div>



<p><code>$ref: "1"</code> is basically a reference to another object, which has already been serialized. In that case, the <code>BestFriend</code> field references the first element of the result array with <code>$id: "1"</code>. It turns out that these are <strong>JSON.NET circular references</strong>. However, you don&#8217;t want these references in your client-side JS code &#8211; you need the actual objects to work with.</p>



<p>I struggled with this issue some time ago in my JavaScript code. In the beginning, I had no idea it might come from the fact that JSON.NET is used for serialization (thanks to our colleague Rafał for pointing that out to me ?). Let&#8217;s see what exactly happens here and why.</p>



<h2 class="wp-block-heading">JSON.NET serialization</h2>



<p>The JS example presented above shows a JSON result received from the following ASP.NET controller method:</p>



<script src="https://gist.github.com/dsibinski/9c1decb2cf139f8078d31d470f643f21.js"></script>



<p>This is the full content of <code>json</code> string after serialization:</p>



<script src="https://gist.github.com/dsibinski/72a6e910965e7f0081ffbf6a0671ef2e.js"></script>



<p>Of course, this is great that JSON.NET does that. Why would we repeat the same objects multiple times in JSONs? The optimization here is that the same objects are serialized once and referenced from all places that use them.</p>



<p>However, if such JSONs are sent to the browser, fields with refs are of no use. We need the actual objects to be there, so we can process the results correctly using JavaScript.</p>



<h2 class="wp-block-heading">Solution 1: fix the issue by reconfiguring JSON.NET serializer</h2>



<p>The first obvious solution could be to configure JSON.NET to not use its optimization for references. Quickly searching through its documentation, we find that <a href="https://www.newtonsoft.com/json/help/html/T_Newtonsoft_Json_PreserveReferencesHandling.htm">PreserveReferencesHandling</a> setting is responsible for that.</p>



<p>If we change our controller&#8217;s code and serialize objects with <code>PreserveReferencesHandling</code> set to <code>None</code>:</p>



<script src="https://gist.github.com/dsibinski/bd56f8b632852ec03daa6a95fdefe658.js"></script>



<p>Our JSON file will look exactly as we&#8217;d expect:</p>



<script src="https://gist.github.com/dsibinski/2386331dd58e4339c7aaace0bf6a9cd0.js"></script>



<p>However, why would we disable JSON.NET circular references? This optimization can sometimes save us huge amounts of data to be sent over the wire. If you have thousands of objects, it might not make sense in sending them all to the client-side code.</p>



<p>You may also have no control of the backend/API you receive the data from. It might as well be dangerous to change the JSON serialization settings, especially if you work on a big project.</p>



<p>If reconfiguration of JSON.NET circular references serialization is not possible in your case, see the other solution (which we also use).</p>



<h2 class="wp-block-heading">Solution 2: resolve circular references using JavaScript</h2>



<p>So we are back to this state in JavaScript:</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="373" height="311" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_CircularReferenceExample.png" alt="JSON result from ASP.NET controller with $ref: &quot;1&quot; instead of a real object" class="wp-image-519" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_CircularReferenceExample.png 373w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/1_CircularReferenceExample-300x250.png 300w" sizes="auto, (max-width: 373px) 100vw, 373px" /></figure></div>



<p>What we want is to have the full objects&#8217; contents instead of <code>$ref</code> elements in our JSON result.</p>



<p>In fact, all the data we need is already there. The first element of the array with <code>$id: "1"</code> is object that should be put in place of all <code>$ref: "1"</code> references.</p>



<p>As you can imagine, this requires a mechanism that would traverse the results tree and replace all these values according to IDs of the referenced objects.</p>



<p>Fortunately, we don&#8217;t need to implement it ourselves. There are few implementations of such a tool, circulating the web.</p>



<p>We use something called <code>JsonNetDecycle</code> which we found few years back already. I noticed there&#8217;s a new version of it ported to TypeScript: <a href="https://github.com/jmackay/angular2-demoproject-aspnetcore/blob/master/Source/Angular2Demo.Web/wwwroot/lib/jsonNetDecycle.ts">jsonNetDecycle.ts</a>. It doesn&#8217;t provide full type support as it is a few years old already, and I didn&#8217;t try it. But you can if you use <a href="https://blog.yumasoft.pl/2021/06/migrating-javascript-react-app-to-typescript/">TypeScript</a> ? There&#8217;s also a <code>cycle.js</code> solution available <a href="https://github.com/douglascrockford/JSON-js/blob/master/cycle.js">here</a> and recommended by many folks. I believe it may also solve our issue, but again &#8211; this is not what we are using.</p>



<p>The version of the  <code>JsonNetDecycle</code>  we use is <a href="https://gist.github.com/johnbabb/2d69374455e386eae87a">this one</a>. Simply create a new file called <code>JsonNetDecycle.js</code> in your project and copy this Gist&#8217;s contents to this file. You can skip the last part starting with <code>(function(console)</code> (line 112) &#8211; we won&#8217;t need it.</p>



<p>Now, we can use the exported <code>JsonNetDecycle.retrocycle()</code> function to &#8220;fix&#8221; our JSON:</p>



<script src="https://gist.github.com/dsibinski/800bd926a0e44d206df688edf4c86bec.js"></script>



<p>Let&#8217;s see whether this works.</p>



<p>This is what we get from the API before resolving JSON.NET circular references:</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="593" height="311" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/2_CircularReferencesExampleWithDetails.png" alt="JSON result from ASP.NET controller with $ref: &quot;1&quot; instead of a real object" class="wp-image-532" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/2_CircularReferencesExampleWithDetails.png 593w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/2_CircularReferencesExampleWithDetails-300x157.png 300w" sizes="auto, (max-width: 593px) 100vw, 593px" /></figure></div>



<p>So we still have references there instead of real objects.</p>



<p>Now let&#8217;s see what happens with the <code>result</code> object after executing <code>JsonNetDecycle.retrocycle()</code> on it:</p>



<div class="wp-block-image"><figure class="aligncenter size-full"><img loading="lazy" decoding="async" width="560" height="323" src="https://blog.yumasoft.pl/wp-content/uploads/2021/08/3_CurcularReferencesRemoved.png" alt="JSON result from ASP.NET controller using JSON.NET without JSON.NET circular references" class="wp-image-533" srcset="https://blog.yumasoft.pl/wp-content/uploads/2021/08/3_CurcularReferencesRemoved.png 560w, https://blog.yumasoft.pl/wp-content/uploads/2021/08/3_CurcularReferencesRemoved-300x173.png 300w" sizes="auto, (max-width: 560px) 100vw, 560px" /></figure></div>



<p>Wohhooa! That&#8217;s what we wanted ? There are no circular references in our JSON response anymore!</p>
<p>The post <a rel="nofollow" href="https://blog.yumasoft.pl/2021/08/how-to-fix-json-net-circular-references-ref-in-javascript/">How To Fix JSON.NET Circular References ($ref) In JavaScript</a> appeared first on <a rel="nofollow" href="https://blog.yumasoft.pl">Yumasoft</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.yumasoft.pl/2021/08/how-to-fix-json-net-circular-references-ref-in-javascript/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
