<?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/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>object &#8211; MaxVergelli.com</title>
	<atom:link href="https://www.maxvergelli.com/tag/object/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.maxvergelli.com</link>
	<description>sourcecode repository</description>
	<lastBuildDate>Sat, 11 Apr 2020 18:40:35 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://i2.wp.com/www.maxvergelli.com/wp-content/uploads/2020/04/wp-1586823685141.png?fit=32%2C32&#038;ssl=1</url>
	<title>object &#8211; MaxVergelli.com</title>
	<link>https://www.maxvergelli.com</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">34603511</site>	<item>
		<title>Display the total number of days between two dates in PHP</title>
		<link>https://www.maxvergelli.com/how-to-display-total-number-of-days-between-two-dates-in-php/</link>
					<comments>https://www.maxvergelli.com/how-to-display-total-number-of-days-between-two-dates-in-php/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Fri, 10 Apr 2020 14:30:00 +0000</pubDate>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[String Manipulation Algorithms]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[count-days]]></category>
		<category><![CDATA[date]]></category>
		<category><![CDATA[date-conversion]]></category>
		<category><![CDATA[date-interval]]></category>
		<category><![CDATA[datetime]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[time-difference]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=147</guid>

					<description><![CDATA[PHP: How to display the total number of days between two dates in PHP, using the DateTime class and compare them via diff() method]]></description>
										<content:encoded><![CDATA[<p>To count the total number of days between two dates, use the <code>DateTime</code> class and compare them via <code>diff()</code> method with the following few lines of code</p>


<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;php&quot;,&quot;mime&quot;:&quot;text/x-php&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;language&quot;:&quot;PHP&quot;,&quot;modeName&quot;:&quot;php&quot;}">$date1 = new DateTime('2020-01-01'); 
$date2 = new DateTime('2020-02-15'); 
print_r($date1-&gt;diff($date2));</pre></div>



<p>And the output will be:</p>



<div class="wp-block-codemirror-blocks-code-block code-block"><pre class="CodeMirror" data-setting="{&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;application/json&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;styleActiveLine&quot;:true,&quot;lineWrapping&quot;:true,&quot;readOnly&quot;:true,&quot;languageLabel&quot;:&quot;no&quot;,&quot;language&quot;:&quot;JSON&quot;,&quot;modeName&quot;:&quot;json&quot;}">DateInterval Object ( 
  [y] =&gt; 0 
  [m] =&gt; 1 
  [d] =&gt; 14 
  [h] =&gt; 0 
  [i] =&gt; 0 
  [s] =&gt; 0 
  [f] =&gt; 0 
  [weekday] =&gt; 0 
  [weekday_behavior] =&gt; 0 
  [first_last_day_of] =&gt; 0 
  [invert] =&gt; 0 
  [days] =&gt; 45 
  [special_type] =&gt; 0 
  [special_amount] =&gt; 0 
  [have_weekday_relative] =&gt; 0 
  [have_special_relative] =&gt; 0 
)</pre></div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-display-total-number-of-days-between-two-dates-in-php/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">147</post-id>	</item>
		<item>
		<title>How to export an ASP Associative Array to XML</title>
		<link>https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/</link>
					<comments>https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Sat, 15 Feb 2020 16:27:57 +0000</pubDate>
				<category><![CDATA[Classic ASP]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[MS Access]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VBScript]]></category>
		<category><![CDATA[XML]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array-function]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[asp-associative-array]]></category>
		<category><![CDATA[associative-array]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[datetime-conversion]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[enumerating]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[helper-class]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[module]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-conversion]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[wrapper-class]]></category>
		<category><![CDATA[xml]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=82</guid>

					<description><![CDATA[&#8220;Asp Associative Array Class&#8221; provides a method to easly export all items to a well formatted XML string. For example, You can create a new *.ASP file : [sourcecode language=&#8221;vb&#8221;] &#60;!&#8211;#include file=&#34;AssociativeArrayClass.asp&#34; &#8211;&#62; &#60;% Dim Person, God Set Person = &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/" aria-label="How to export an ASP Associative Array to XML">Read More</a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://sourceforge.net/projects/asp-assoc-array/files/ASP_Associative_Array.rar/download" target="_blank" rel="noopener noreferrer">&#8220;Asp Associative Array Class&#8221;</a> provides a method to easly export all items to a well formatted XML string. For example, You can create a new *.ASP file :</p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
&lt;!&#8211;#include file=&quot;AssociativeArrayClass.asp&quot; &#8211;&gt;<br />
&lt;%<br />
Dim Person, God<br />
Set Person = New AssociativeArray<br />
Set God = New AssociativeArray<br />
Person(&quot;name&quot;) = &quot;Max&quot;<br />
Person(&quot;surname&quot;) = &quot;Vergelli&quot;<br />
God(&quot;name&quot;) = &quot;Jesus&quot;<br />
God(&quot;surname&quot;) = &quot;Christ&quot;<br />
Dim World<br />
Set World = New AssociativeArray<br />
World(1) = Person<br />
World(2) = God<br />
response.Write World.ToXML()<br />
%&gt;<br />
[/sourcecode]</p>
<p>And You will get out the following XML:</p>
<p>[sourcecode language=&#8221;xml&#8221;]<br />
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br />
&lt;array&gt;<br />
      &lt;key&gt;<br />
            &lt;name&gt;&lt;![CDATA[1]]&gt;&lt;/name&gt;<br />
            &lt;value&gt;<br />
                    &lt;key&gt;<br />
                           &lt;name&gt;&lt;![CDATA[name]]&gt;&lt;/name&gt;<br />
                           &lt;value&gt;&lt;![CDATA[Max]]&gt;&lt;/value&gt;<br />
                    &lt;/key&gt;<br />
                    &lt;key&gt;<br />
                           &lt;name&gt;&lt;![CDATA[surname]]&gt;&lt;/name&gt;<br />
                           &lt;value&gt;&lt;![CDATA[Vergelli]]&gt;&lt;/value&gt;<br />
                   &lt;/key&gt;<br />
           &lt;/value&gt;<br />
      &lt;/key&gt;<br />
      &lt;key&gt;<br />
             &lt;name&gt;&lt;![CDATA[2]]&gt;&lt;/name&gt;<br />
             &lt;value&gt;<br />
                    &lt;key&gt;<br />
                           &lt;name&gt;&lt;![CDATA[name]]&gt;&lt;/name&gt;<br />
                           &lt;value&gt;&lt;![CDATA[Jesus]]&gt;&lt;/value&gt;<br />
                    &lt;/key&gt;<br />
                    &lt;key&gt;<br />
                          &lt;name&gt;&lt;![CDATA[surname]]&gt;&lt;/name&gt;<br />
                          &lt;value&gt;&lt;![CDATA[Christ]]&gt;&lt;/value&gt;<br />
                    &lt;/key&gt;<br />
             &lt;/value&gt;<br />
       &lt;/key&gt;<br />
&lt;/array&gt;<br />
[/sourcecode]</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-export-an-asp-associative-array-to-xml/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">82</post-id>	</item>
		<item>
		<title>vb.net Bitmap object locks images (impossible to move/delete jpg/gif files) &#8211; .Dispose() Method common problem</title>
		<link>https://www.maxvergelli.com/vb-net-bitmap-object-locks-images-impossible-to-move-delete-jpg-gif-files-dispose-method-common-problem/</link>
					<comments>https://www.maxvergelli.com/vb-net-bitmap-object-locks-images-impossible-to-move-delete-jpg-gif-files-dispose-method-common-problem/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Tue, 14 Jan 2020 15:47:04 +0000</pubDate>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[VB.Net]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[bitmap]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[dispose]]></category>
		<category><![CDATA[file]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[vb.net]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=74</guid>

					<description><![CDATA[Many people are in trouble and on forums asking why the .Net Bitmap object does not release an image with its .Dispose() method. The Bitmap object (after its destruction too) seems to lock the image file, then we are not &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/vb-net-bitmap-object-locks-images-impossible-to-move-delete-jpg-gif-files-dispose-method-common-problem/" aria-label="vb.net Bitmap object locks images (impossible to move/delete jpg/gif files) &#8211; .Dispose() Method common problem">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>Many people are in trouble and on forums asking why the .Net Bitmap object does not release an image with its .Dispose() method. The Bitmap object (after its destruction too) seems to lock the image file, then we are not able to move or delete that image file through the file system.</p>
<p>This is a known problem and it occurs when we declare and instantiate a Bitmap object and destruct that like in the following code:</p>
<p>[sourcecode language=&#8221;vb&#8221;]</p>
<p>                &#8216;create a bitmap object<br />
                Dim myBitmap As New Bitmap(&quot;c:myimage.jpg&quot;)</p>
<p>                &#8216;editing image routines, right here<br />
                &#8216;&#8230;</p>
<p>                &#8216;release all Bitmap object resources<br />
                myBitmap.Dispose()</p>
<p>[/sourcecode]</p>
<p>The above code it is formally correct, however in same circumstances the .net garbage collector cannot recognize bitmap&#8217;s disposing; Dispose() method leaves the image file in an unusable state, then as <a href="http://msdn.microsoft.com/en-us/library/8th8381z.aspx">MSDN</a> said, we MUST release explicitly any reference after a Dispose() call;</p>
<p>with the following code, You will not encounter any problem, and after Dispose() You can edit, move, delete the image file by the filesystem functions&#8230;</p>
<p>[sourcecode language=&#8221;vb&#8221;]<br />
                &#8216;create a bitmap object<br />
                Dim myBitmap As New Bitmap(&quot;c:myimage.jpg&quot;)</p>
<p>                &#8216;editing image routines, right here<br />
                &#8216;&#8230;</p>
<p>                &#8216;release image reference<br />
                While myBitmap IsNot Nothing<br />
                    myBitmap.Dispose()<br />
                    myBitmap = Nothing  &#8216;&lt;&#8211; tells .net garbage collector to release resources<br />
                End While</p>
<p>[/sourcecode]</p>
<p>Happy image editing! 🙂</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/vb-net-bitmap-object-locks-images-impossible-to-move-delete-jpg-gif-files-dispose-method-common-problem/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">74</post-id>	</item>
		<item>
		<title>Online JSON Validator</title>
		<link>https://www.maxvergelli.com/online-json-validator/</link>
					<comments>https://www.maxvergelli.com/online-json-validator/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Mon, 06 Jan 2020 15:16:20 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[data]]></category>
		<category><![CDATA[data-layer]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[enumerating]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-conversion]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[structure]]></category>
		<category><![CDATA[validator]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=61</guid>

					<description><![CDATA[If You are bored of having to test many JSON structures in JavaScript, You can validate your JSON data with this useful online tool: http://jsonlint.com/]]></description>
										<content:encoded><![CDATA[<p>If You are bored of having to test many JSON structures in JavaScript, You can validate your JSON data with this useful online tool: <a href="http://jsonlint.com/">http://jsonlint.com/</a> </p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/online-json-validator/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">61</post-id>	</item>
		<item>
		<title>Javascript isArray() function</title>
		<link>https://www.maxvergelli.com/javascript-isarray-function/</link>
					<comments>https://www.maxvergelli.com/javascript-isarray-function/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Fri, 01 Nov 2019 14:50:42 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[array-function]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[datatype]]></category>
		<category><![CDATA[enumerate]]></category>
		<category><![CDATA[extension]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[isarray-function]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[method]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[typeof]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=55</guid>

					<description><![CDATA[Javascript does not provide a function to recognize if a variable is an array or not; you can make a &#8220;typeof&#8221; of the variable however u&#8217;ll get an &#8216;object&#8217; datatype, as in the following code [sourcecode language=&#8221;javascript&#8221;] var myarray = &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/javascript-isarray-function/" aria-label="Javascript isArray() function">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>Javascript does not provide a function to recognize if a variable is an array or not; you can make a &#8220;typeof&#8221; of the variable however u&#8217;ll get an &#8216;object&#8217; datatype, as in the following code<br />
[sourcecode language=&#8221;javascript&#8221;]<br />
var myarray = [1, 2, 3];<br />
var myobject = { key: &#8216;value&#8217; };<br />
alert(typeof myarray); //return &#8216;object&#8217;<br />
alert(typeof myobject); //return &#8216;object&#8217;<br />
[/sourcecode]</p>
<p>to recognize a data type &#8216;object&#8217; from &#8216;array&#8217;, you need a specialized function like this&#8230;<br />
[sourcecode language=&#8221;javascript&#8221;]<br />
function isArray(value){<br />
	var b = typeof value;<br />
	if(b === &#8216;object&#8217;){<br />
		if(value){<br />
			b = (typeof value.length === &#8216;number&#8217; &amp;&amp;<br />
				!(value.propertyIsEnumerable(&#8216;length&#8217;)) &amp;&amp;<br />
				typeof value.splice === &#8216;function&#8217;) ? true : false;<br />
		}else{<br />
			b = false;<br />
		};<br />
	};<br />
	return b;<br />
};<br />
var myarray = [1, 2, 3];<br />
var myobject = { key: &#8216;value&#8217; };<br />
alert(isArray(myarray)); //return true<br />
alert(isArray(myobject)); //return false<br />
[/sourcecode]</p>
<p>Good work!<br />
Max 🙂</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/javascript-isarray-function/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">55</post-id>	</item>
		<item>
		<title>How to stringify an object in Javascript: converting an object to a padded &#038; well-formatted string or simply inline</title>
		<link>https://www.maxvergelli.com/how-to-stringify-an-object-in-javascript-converting-an-object-to-a-padded-well-formatted-string-or-simply-inline/</link>
					<comments>https://www.maxvergelli.com/how-to-stringify-an-object-in-javascript-converting-an-object-to-a-padded-well-formatted-string-or-simply-inline/#respond</comments>
		
		<dc:creator><![CDATA[Max]]></dc:creator>
		<pubDate>Tue, 01 Oct 2019 14:45:36 +0000</pubDate>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[String Manipulation Algorithms]]></category>
		<category><![CDATA[algorithm]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[filtering]]></category>
		<category><![CDATA[formatting]]></category>
		<category><![CDATA[function]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[object]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[parsing]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[string]]></category>
		<category><![CDATA[string-manipulation]]></category>
		<category><![CDATA[stringification]]></category>
		<category><![CDATA[stringify]]></category>
		<guid isPermaLink="false">http://www.maxvergelli.com/?p=53</guid>

					<description><![CDATA[I wrote a function to convert an object in a string (stringification) without using a JSON library; you can convert an object to a well formatted string with padding or simply to an unique line: [sourcecode language=&#8221;javascript&#8221;] function stringify(object, padding, &#8230; <a class="kt-excerpt-readmore" href="https://www.maxvergelli.com/how-to-stringify-an-object-in-javascript-converting-an-object-to-a-padded-well-formatted-string-or-simply-inline/" aria-label="How to stringify an object in Javascript: converting an object to a padded &#038; well-formatted string or simply inline">Read More</a>]]></description>
										<content:encoded><![CDATA[<p>I wrote a function to convert an object in a string (stringification) without using a JSON library; you can convert an object to a well formatted string with padding or simply to an unique line:</p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
function stringify(object, padding, margin){<br />
	var o = (typeof object == &#8216;object&#8217; || typeof object == &#8216;function&#8217;) &amp;&amp; object != null ? object : null;<br />
	var p = typeof padding == &#8216;boolean&#8217; &amp;&amp; padding ? true : false;<br />
	var m = typeof margin == &#8216;number&#8217; &amp;&amp; margin&gt;0 &amp;&amp; p ? margin : 0;<br />
	if(o != null){<br />
		var s = &#8221;;<br />
		var a = function(o){return (typeof o === &#8216;object&#8217; &amp;&amp; o ? ((typeof o.length === &#8216;number&#8217; &amp;&amp;!(o.propertyIsEnumerable(&#8216;length&#8217;)) &amp;&amp; typeof o.splice === &#8216;function&#8217;) ? true : false) : false);}; //is array?<br />
		for(var v in o){<br />
			s += typeof o[v] === &#8216;object&#8217; ? (o[v] ? (<br />
					(typeof o[v].length === &#8216;number&#8217; &amp;&amp; !(o[v].propertyIsEnumerable(&#8216;length&#8217;)) &amp;&amp; typeof o[v].splice === &#8216;function&#8217;) ?<br />
					(m&gt;0 ? Array(m).join(&#8216; &#8216;):&#8221;) + v + &#8216;:&#8217; + (p ? &#8216; &#8216;:&#8221;) + &#8216;[&#8216; + (p ? &#8216;rn&#8217;:&#8221;) + stringify(o[v],p,(m&gt;0?m:1)+v.length+4) + (p!=true ? &#8221; : &#8216;rn&#8217; + Array((m&gt;0?m:1)+v.length+2).join(&#8216; &#8216;)) + &#8216;],&#8217; + (p ? &#8216;rn&#8217;:&#8221;) :<br />
					(m&gt;0 ? Array(m).join(&#8216; &#8216;):&#8221;) + v + &#8216;:&#8217; + (p ? &#8216; &#8216;:&#8221;) + &#8216;{&#8216; + (p ? &#8216;rn&#8217;:&#8221;) + stringify(o[v],p,(m&gt;0?m:1)+v.length+4) + (p!=true ? &#8221; : &#8216;rn&#8217; + Array((m&gt;0?m:1)+v.length+2).join(&#8216; &#8216;)) + &#8216;},&#8217; + (p ? &#8216;rn&#8217;:&#8221;)<br />
				) : (m&gt;0 ? Array(m).join(&#8216; &#8216;):&#8221;) + v + &#8216;:&#8217; + (p ? &#8216; &#8216;:&#8221;) + o[v] + &#8216;,&#8217; + (p ? &#8216;rn&#8217;:&#8221;))<br />
			: (m&gt;0 ? Array(m).join(&#8216; &#8216;):&#8221;) + v + &#8216;:&#8217; + (p ? &#8216; &#8216;:&#8221;) + (typeof o[v] == &#8216;string&#8217; ? &#8221;&#8217; + o[v].replace(/&#8217;/g,&#8217;\&#8221;) + &#8221;&#8217; : o[v]) + &#8216;,&#8217; + (p ? &#8216;rn&#8217;:&#8221;);<br />
		};<br />
		o = s.length&gt;0 &amp;&amp; p!=true ? s.substring(0, s.length-1) : (s.length&gt;2 ? s.substring(0, s.length-3) : s);<br />
	}else{<br />
		o = object;<br />
	};<br />
	return o;<br />
};<br />
[/sourcecode]</p>
<p><strong>a little example, you declare same variable&#8230;.</strong></p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
var associative_array = new Array();<br />
associative_array[&#8216;one&#8217;] = 1;<br />
associative_array[&#8216;two&#8217;] = 2;<br />
associative_array[&#8216;undefinedvar&#8217;];</p>
<p>var myobject = {<br />
					mystring: &#8216;value&#8217;,<br />
					myquoted: &#8216;string with &#8216;single quotation mark&#8221;,<br />
					mynumber: 1,<br />
					myboolean: true,<br />
					myarray: [1, 2, 3],<br />
					myassocarray: associative_array,<br />
					myobject: {<br />
								obj_string: &#8216;hi!&#8217;,<br />
								obj_number: 1,<br />
								obj_array: [<br />
												&#8216;just&#8217;, &#8216;a&#8217;, &#8216;test&#8217;, 1, false,<br />
												[&#8216;array&#8217;, &#8216;inside&#8217;, &#8216;array&#8217;],<br />
												{<br />
													object: &#8216;inside array&#8217;,<br />
													array: [1,2,3,4,5,6,7,8,9]<br />
												},</p>
<p>											]<br />
								},<br />
					mynullvalue: null,<br />
					myundefined: associative_array[&#8216;undefinedvar&#8217;],<br />
					myfunction: function(){ var s = &#8216;hello!&#8217;; return s; }<br />
				};<br />
[/sourcecode]</p>
<p><strong>then, for an inline stringification, you can use</strong></p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
var str = stringify(myobject);<br />
[/sourcecode]</p>
<p><strong>and &#8220;str&#8221; value will be a string as</strong></p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
mystring:&#8217;value&#8217;,myquoted:&#8217;string with &#8216;single quotation mark&#8221;,mynumber:1,myboolean:true,myarray:[0:1,1:2,2:3],myassocarray:[one:1,two:2],myobject:{obj_string:&#8217;hi!&#8217;,obj_number:1,obj_array:[0:&#8217;just&#8217;,1:&#8217;a&#8217;,2:&#8217;test&#8217;,3:1,4:false,5:[0:&#8217;array&#8217;,1:&#8217;inside&#8217;,2:&#8217;array&#8217;],6:{object:&#8217;inside array&#8217;,array:[0:1,1:2,2:3,3:4,4:5,5:6,6:7,7:8,8:9]}]},mynullvalue:null,myundefined:undefined,myfunction:function () {<br />
    var s = &quot;hello!&quot;;<br />
    return s;<br />
}<br />
[/sourcecode]</p>
<p><strong>Instead, for a stringification with a well formatted padding, you can use</strong></p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
var str_formatted = stringify(myobject, true);<br />
[/sourcecode]</p>
<p><strong>and this is the &#8220;str_formatted&#8221; value:</strong></p>
<p>[sourcecode language=&#8221;javascript&#8221;]<br />
mystring: &#8216;value&#8217;,<br />
myquoted: &#8216;string with &#8216;single quotation mark&#8221;,<br />
mynumber: 1,<br />
myboolean: true,<br />
myarray: [<br />
           0: 1,<br />
           1: 2,<br />
           2: 3<br />
         ],<br />
myassocarray: [<br />
                one: 1,<br />
                two: 2<br />
              ],<br />
myobject: {<br />
            obj_string: &#8216;hi!&#8217;,<br />
            obj_number: 1,<br />
            obj_array: [<br />
                         0: &#8216;just&#8217;,<br />
                         1: &#8216;a&#8217;,<br />
                         2: &#8216;test&#8217;,<br />
                         3: 1,<br />
                         4: false,<br />
                         5: [<br />
                              0: &#8216;array&#8217;,<br />
                              1: &#8216;inside&#8217;,<br />
                              2: &#8216;array&#8217;<br />
                            ],<br />
                         6: {<br />
                              object: &#8216;inside array&#8217;,<br />
                              array: [<br />
                                       0: 1,<br />
                                       1: 2,<br />
                                       2: 3,<br />
                                       3: 4,<br />
                                       4: 5,<br />
                                       5: 6,<br />
                                       6: 7,<br />
                                       7: 8,<br />
                                       8: 9<br />
                                     ]<br />
                            }<br />
                       ]<br />
          },<br />
mynullvalue: null,<br />
myundefined: undefined,<br />
myfunction: function () {<br />
    var s = &quot;hello!&quot;;<br />
    return s;<br />
}<br />
[/sourcecode]</p>
<p>Finally, when you pass a variable to stringify() that is not an object, it will just return the value.</p>
<p>Happy stringifications!</p>
<p>Max 🙂</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.maxvergelli.com/how-to-stringify-an-object-in-javascript-converting-an-object-to-a-padded-well-formatted-string-or-simply-inline/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">53</post-id>	</item>
	</channel>
</rss>
