<?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>Werx Limited &#187; recursive</title>
	<atom:link href="http://werxltd.com/wp/tag/recursive/feed/" rel="self" type="application/rss+xml" />
	<link>http://werxltd.com/wp</link>
	<description>We make IT work.</description>
	<lastBuildDate>Wed, 08 Sep 2010 17:00:45 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Magical PHP JSON Object Cleaner</title>
		<link>http://werxltd.com/wp/2009/07/29/magical-php-json-object-cleaner/</link>
		<comments>http://werxltd.com/wp/2009/07/29/magical-php-json-object-cleaner/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 14:27:03 +0000</pubDate>
		<dc:creator>wes</dc:creator>
				<category><![CDATA[software development]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[recursive]]></category>

		<guid isPermaLink="false">http://werxltd.com/wp/?p=159</guid>
		<description><![CDATA[I wrote this method the other day that takes a simple PHP object, inspects it&#8217;s properties and &#8220;prunes&#8221; empty ones. I wrote this method in order to compress JSON objects by removing null properties before sending them down the wire, a big problem when using base objects or models. If you find this useful or [...]]]></description>
			<content:encoded><![CDATA[<p>I wrote this method the other day that takes a simple PHP object, inspects it&#8217;s properties and &#8220;prunes&#8221; empty ones. I wrote this method in order to compress JSON objects by removing null properties before sending them down the wire, a big problem when using base objects or models.</p>
<p>If you find this useful or a have a suggestion, feel free to let me know!</p>
<pre class="brush:php">
private function getStripped($obj) {
		$objVars = get_object_vars($obj);

		if(count($objVars) > 0) {
			foreach($objVars as $propName => $propVal) {
				if(gettype($propVal) == "object") {
					$cObj = $this->getStripped($propVal);
					if($cObj == null) {
						unset($obj->$propName);
					} else {
						$obj->$propName = $cObj;
					}
				} else {
					if(empty($propVal)) {
						unset($obj->$propName);
					}
				}
			}
		} else {
			return null;
		}
		return $obj;
	}</pre>
]]></content:encoded>
			<wfw:commentRss>http://werxltd.com/wp/2009/07/29/magical-php-json-object-cleaner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
