<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
	
	>
<channel>
	<title>
	Comments on: JSON-Matlab integration	</title>
	<atom:link href="https://undocumentedmatlab.com/articles/json-matlab-integration/feed" rel="self" type="application/rss+xml" />
	<link>https://undocumentedmatlab.com/articles/json-matlab-integration?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=json-matlab-integration</link>
	<description>Professional Matlab consulting, development and training</description>
	<lastBuildDate>Sun, 18 Sep 2016 22:44:39 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.2</generator>
	<item>
		<title>
		By: Oliver Woodford		</title>
		<link>https://undocumentedmatlab.com/articles/json-matlab-integration#comment-388693</link>

		<dc:creator><![CDATA[Oliver Woodford]]></dc:creator>
		<pubDate>Sun, 18 Sep 2016 22:44:39 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4738#comment-388693</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/json-matlab-integration#comment-381350&quot;&gt;Oleg&lt;/a&gt;.

Reading from a JSON still isn&#039;t as fas as it could be. My &lt;a href=&quot;https://uk.mathworks.com/matlabcentral/fileexchange/59166-json-read&quot; rel=&quot;nofollow&quot;&gt;json_read mex function&lt;/a&gt; is over 10x faster than &lt;code&gt;fromJSON(fileread(&#039;filename.json&#039;))&lt;/code&gt;.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/json-matlab-integration#comment-381350">Oleg</a>.</p>
<p>Reading from a JSON still isn&#8217;t as fas as it could be. My <a href="https://uk.mathworks.com/matlabcentral/fileexchange/59166-json-read" rel="nofollow">json_read mex function</a> is over 10x faster than <code>fromJSON(fileread('filename.json'))</code>.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Mariusz Zaleski		</title>
		<link>https://undocumentedmatlab.com/articles/json-matlab-integration#comment-385752</link>

		<dc:creator><![CDATA[Mariusz Zaleski]]></dc:creator>
		<pubDate>Mon, 15 Aug 2016 12:45:11 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4738#comment-385752</guid>

					<description><![CDATA[Hi,

Is there anything that would work in C# parsing JSON to MatLab native types? (MWCharArray, MWNumericalArray etc)]]></description>
			<content:encoded><![CDATA[<p>Hi,</p>
<p>Is there anything that would work in C# parsing JSON to MatLab native types? (MWCharArray, MWNumericalArray etc)</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Oleg		</title>
		<link>https://undocumentedmatlab.com/articles/json-matlab-integration#comment-381350</link>

		<dc:creator><![CDATA[Oleg]]></dc:creator>
		<pubDate>Sat, 25 Jun 2016 21:59:49 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4738#comment-381350</guid>

					<description><![CDATA[As of R2016a the core of &lt;code&gt;matlab.internal.webservices.toJSON()&lt;/code&gt; and &lt;code&gt;matlab.internal.webservices.fromJSON()&lt;/code&gt; are in mex, hence very fast.]]></description>
			<content:encoded><![CDATA[<p>As of R2016a the core of <code>matlab.internal.webservices.toJSON()</code> and <code>matlab.internal.webservices.fromJSON()</code> are in mex, hence very fast.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Malcolm Lidierth		</title>
		<link>https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373405</link>

		<dc:creator><![CDATA[Malcolm Lidierth]]></dc:creator>
		<pubDate>Thu, 31 Mar 2016 17:46:10 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4738#comment-373405</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373351&quot;&gt;oro77&lt;/a&gt;.

@oro77
The number of digits used depends on the JSon library and how it does the formatting. Sun/Oracle/openJDK provide a full spec for the &lt;code&gt;java.lang.Double.toString()&lt;/code&gt; method. Remembering that MATLAB calls that method to get the text to display in the MATLAB Command Window for Java objects including Double, the following may be informative:

&lt;pre lang=&quot;matlab&quot;&gt;
&gt;&gt; a = java.lang.Double(&#039;0.1&#039;)
a =
0.1
 
&gt;&gt; b = java.lang.Double(&#039;0.10000000000000001&#039;)
b =
0.1 
 
&gt;&gt; a==b
ans =
     1

&gt;&gt; java.lang.Double(0.1)==java.lang.Double(&#039;0.1&#039;)
ans =
     1
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373351">oro77</a>.</p>
<p>@oro77<br />
The number of digits used depends on the JSon library and how it does the formatting. Sun/Oracle/openJDK provide a full spec for the <code>java.lang.Double.toString()</code> method. Remembering that MATLAB calls that method to get the text to display in the MATLAB Command Window for Java objects including Double, the following may be informative:</p>
<pre lang="matlab">
>> a = java.lang.Double('0.1')
a =
0.1
 
>> b = java.lang.Double('0.10000000000000001')
b =
0.1 
 
>> a==b
ans =
     1

>> java.lang.Double(0.1)==java.lang.Double('0.1')
ans =
     1
</pre>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: oro77		</title>
		<link>https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373355</link>

		<dc:creator><![CDATA[oro77]]></dc:creator>
		<pubDate>Thu, 31 Mar 2016 08:45:36 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4738#comment-373355</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373351&quot;&gt;oro77&lt;/a&gt;.

@Yair Altman - Thank you for your advice. I was thinking about rounding off it but the user may want to edit the json file in a text editor and he may find awkward about the insignificant digits. It is hard to decide what is the best solution. Is there something wrong about storing string representations in the JSON payload ?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373351">oro77</a>.</p>
<p>@Yair Altman &#8211; Thank you for your advice. I was thinking about rounding off it but the user may want to edit the json file in a text editor and he may find awkward about the insignificant digits. It is hard to decide what is the best solution. Is there something wrong about storing string representations in the JSON payload ?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Yair Altman		</title>
		<link>https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373353</link>

		<dc:creator><![CDATA[Yair Altman]]></dc:creator>
		<pubDate>Thu, 31 Mar 2016 08:26:23 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4738#comment-373353</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373351&quot;&gt;oro77&lt;/a&gt;.

@oro77 - I would think that it would make more sense to simply round off the insignificant digits upon loading/displaying (in those rare cases where this difference in LSB makes any difference), rather than store string representations in the JSON payload.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373351">oro77</a>.</p>
<p>@oro77 &#8211; I would think that it would make more sense to simply round off the insignificant digits upon loading/displaying (in those rare cases where this difference in LSB makes any difference), rather than store string representations in the JSON payload.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: oro77		</title>
		<link>https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373351</link>

		<dc:creator><![CDATA[oro77]]></dc:creator>
		<pubDate>Thu, 31 Mar 2016 08:19:36 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4738#comment-373351</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373320&quot;&gt;Malcolm Lidierth&lt;/a&gt;.

Thank you for your reply. 
So the best way to keep 0.1 would be to store in my structure a string instead of a double value.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373320">Malcolm Lidierth</a>.</p>
<p>Thank you for your reply.<br />
So the best way to keep 0.1 would be to store in my structure a string instead of a double value.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Malcolm Lidierth		</title>
		<link>https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373320</link>

		<dc:creator><![CDATA[Malcolm Lidierth]]></dc:creator>
		<pubDate>Thu, 31 Mar 2016 05:12:04 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4738#comment-373320</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373312&quot;&gt;oro77&lt;/a&gt;.

For a long answer:
&lt;a href=&quot;http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html&quot; rel=&quot;nofollow&quot;&gt;What Every Computer Scientist Should Know About Floating-Point Arithmetic&lt;/a&gt;, by David Goldberg, published in the March, 1991 issue of Computing Surveys. Copyright 1991, Association for Computing Machinery, Inc.

Short answer:
Just as 1/3 can not be exactly represented in decimal, 1/10 has no exact representation in binary.

The &lt;code&gt;java.lang.Double&lt;/code&gt; class is probably underused by MATLABers: its &lt;i&gt;toString()&lt;/i&gt; method returns a string representation of a double that  uses the minimum number of digits required to exactly reproduce that double during deserialisation (i.e to get back to that member of the subset of numbers represented in IEEE double).

&lt;code&gt;java.lang.Double&lt;/code&gt; uses the &lt;a href=&quot;http://www.docjar.com/html/api/sun/misc/FloatingDecimal.java.html&quot; rel=&quot;nofollow&quot;&gt;FloatingDecimal class&lt;/a&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373312">oro77</a>.</p>
<p>For a long answer:<br />
<a href="http://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html" rel="nofollow">What Every Computer Scientist Should Know About Floating-Point Arithmetic</a>, by David Goldberg, published in the March, 1991 issue of Computing Surveys. Copyright 1991, Association for Computing Machinery, Inc.</p>
<p>Short answer:<br />
Just as 1/3 can not be exactly represented in decimal, 1/10 has no exact representation in binary.</p>
<p>The <code>java.lang.Double</code> class is probably underused by MATLABers: its <i>toString()</i> method returns a string representation of a double that  uses the minimum number of digits required to exactly reproduce that double during deserialisation (i.e to get back to that member of the subset of numbers represented in IEEE double).</p>
<p><code>java.lang.Double</code> uses the <a href="http://www.docjar.com/html/api/sun/misc/FloatingDecimal.java.html" rel="nofollow">FloatingDecimal class</a></p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: oro77		</title>
		<link>https://undocumentedmatlab.com/articles/json-matlab-integration#comment-373312</link>

		<dc:creator><![CDATA[oro77]]></dc:creator>
		<pubDate>Thu, 31 Mar 2016 03:25:53 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4738#comment-373312</guid>

					<description><![CDATA[I am using the following command to create the JSON string.
&lt;pre lang=&quot;matlab&quot;&gt;
jsonString = matlab.internal.webservices.toJSON(s);
&lt;/pre&gt;

It works but if my structure is using a real like below.

&lt;pre lang=&quot;matlab&quot;&gt;
s = struct(&#039;this&#039;, {&#039;a&#039;, &#039;b&#039;}, &#039;that&#039;, {0.1, 2})
&lt;/pre&gt;

jsonString will return 
&lt;pre lang=&quot;json&quot;&gt;[{&quot;this&quot;:&quot;a&quot;,&quot;that&quot;:0.10000000000000001},{&quot;this&quot;:&quot;b&quot;,&quot;that&quot;:2}]&lt;/pre&gt;
Why is it 0.10000000000000001 instead of 0.1 ?
How can I correct this ?]]></description>
			<content:encoded><![CDATA[<p>I am using the following command to create the JSON string.</p>
<pre lang="matlab">
jsonString = matlab.internal.webservices.toJSON(s);
</pre>
<p>It works but if my structure is using a real like below.</p>
<pre lang="matlab">
s = struct('this', {'a', 'b'}, 'that', {0.1, 2})
</pre>
<p>jsonString will return </p>
<pre lang="json">[{"this":"a","that":0.10000000000000001},{"this":"b","that":2}]</pre>
<p>Why is it 0.10000000000000001 instead of 0.1 ?<br />
How can I correct this ?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Brad Stiritz		</title>
		<link>https://undocumentedmatlab.com/articles/json-matlab-integration#comment-365672</link>

		<dc:creator><![CDATA[Brad Stiritz]]></dc:creator>
		<pubDate>Thu, 31 Dec 2015 04:08:36 +0000</pubDate>
		<guid isPermaLink="false">http://undocumentedmatlab.com/?p=4738#comment-365672</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://undocumentedmatlab.com/articles/json-matlab-integration#comment-363766&quot;&gt;ET&lt;/a&gt;.

ET, I tried your code without success in R2015a :

&lt;pre lang=&quot;matlab&quot;&gt; 
&gt;&gt; matlab.internal.webservices.toJSON(&#039;abc&#039;)
Undefined variable &quot;matlab&quot; or class &quot;matlab.internal.webservices.toJSON&quot;.
&lt;/pre&gt;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://undocumentedmatlab.com/articles/json-matlab-integration#comment-363766">ET</a>.</p>
<p>ET, I tried your code without success in R2015a :</p>
<pre lang="matlab"> 
>> matlab.internal.webservices.toJSON('abc')
Undefined variable "matlab" or class "matlab.internal.webservices.toJSON".
</pre>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
