Yea so i got a friend called SaltwaterC that has a friend called Json (it reads Jason) and i have met him… a lightweight dude, that can make your life easier.

Here is an simple example:

{
    "created_at": "Tue May 11 11:50:14 +0000 2010",
    "in_reply_to_screen_name": null,
    "favorited": false,
    "truncated": false,
    "source": "<a href="http://destroytwitter.com/" rel="nofollow">DestroyTwitter</a>",
    "in_reply_to_status_id": null,
    "place": null,
    "contributors": null,
    "user": {
        "notifications": false,
        "profile_background_tile": false,
        "profile_sidebar_fill_color": "1A1B1F",
        "description": "Anticrist Superstar Programmer, Head editor @ w2.ro, Pro Drinker, slaker and typo expert.",
        "lang": "en",
        "verified": false,
        "created_at": "Thu Jun 19 15:17:28 +0000 2008",
        "profile_sidebar_border_color": "1A1B1F",
        "profile_image_url": "http://a3.twimg.com/profile_images/842271117/ochelari_normal.jpg",
        "following": true,
        "followers_count": 1017,
        "screen_name": "necenzurat",
        "statuses_count": 9385,
        "profile_background_color": "000000",
        "url": "http://w2.ro",
        "time_zone": "Bucharest",
        "friends_count": 454,
        "contributors_enabled": false,
        "profile_text_color": "666666",
        "protected": false,
        "location": "Bucharest, Romania",
        "favourites_count": 15,
        "name": "Costin M.",
        "profile_background_image_url": "http://a3.twimg.com/profile_background_images/81980881/twtbg.png",
        "profile_link_color": "1e8f89",
        "id": 15169998,
        "geo_enabled": true,
        "utc_offset": 7200
    },
    "coordinates": null,
    "in_reply_to_user_id": null,
    "id": 13784107904,
    "geo": null,
    "text": "WikiLeaks has probably produced more scoops in its short life than the Washington Post has in the past 30 years http://p.ly/ad4rb"
}

And now Mr. XML

<?xml version="1.0" encoding="UTF-8"?>
<status>
  <created_at>Tue May 11 11:50:14 +0000 2010</created_at>
  <id>13784107904</id>
  <text>WikiLeaks has probably produced more scoops in its short life than the Washington Post has in the past 30 years http://p.ly/ad4rb</text>
  <source>&lt;a href="http://destroytwitter.com/" rel="nofollow"&gt;DestroyTwitter&lt;/a&gt;</source>
  <truncated>false</truncated>
  <in_reply_to_status_id/>
  <in_reply_to_user_id/>
  <favorited>false</favorited>
  <in_reply_to_screen_name/>
  <user>
    <id>15169998</id>
    <name>Costin M.</name>
    <screen_name>necenzurat</screen_name>
    <location>Bucharest, Romania</location>
    <description>Anticrist Superstar Programmer, Head editor @ w2.ro, Pro Drinker, slaker and typo expert.</description>
    <profile_image_url>http://a3.twimg.com/profile_images/842271117/
ochelari_normal.jpg</profile_image_url>
    <url>http://w2.ro</url>
    <protected>false</protected>
    <followers_count>1017</followers_count>
    <profile_background_color>000000</profile_background_color>
    <profile_text_color>666666</profile_text_color>
    <profile_link_color>1e8f89</profile_link_color>
    <profile_sidebar_fill_color>1A1B1F</profile_sidebar_fill_color>
    <profile_sidebar_border_color>1A1B1F</profile_sidebar_border_color>
    <friends_count>454</friends_count>
    <created_at>Thu Jun 19 15:17:28 +0000 2008</created_at>
    <favourites_count>15</favourites_count>
    <utc_offset>7200</utc_offset>
    <time_zone>Bucharest</time_zone>
    <profile_background_image_url>http://a3.twimg.com/profile_background_images/
81980881/twtbg.png</profile_background_image_url>
    <profile_background_tile>false</profile_background_tile>
    <notifications>false</notifications>
    <geo_enabled>true</geo_enabled>
    <verified>false</verified>
    <following>false</following>
    <statuses_count>9385</statuses_count>
    <lang>en</lang>
    <contributors_enabled>false</contributors_enabled>
  </user>
  <geo/>
  <coordinates/>
  <place/>
  <contributors/>
</status>

First of all:
JSON can be parser is one freaking like

$json = json_decode($file, true);

and the XML… well i don’t want to get into details

Second: the upper examples are in size:
JSON – 1,37 KB (1.406 bytes)
XML – 2,04 KB (2.090 bytes)
and yes, when you are doing an import of 15.000 products from XML every thing counts.

If this has been useful you should give me a beer

One response


Do you want to comment?

Comments RSS and TrackBack Identifier URI ?

YES!

Sure, for the first few years, XML did a (very specific) job that nothing else did, but…

FUCK XML!!!

It got blown all out of proportion and shouldn’t be used for 95% of what it’s doing these days. It’s fucking lousy. We need a regular, standardized architecture and language for distributed object handling, not kitchen sink hax like XML crap.

Did I mention… FUCK XML! And FUCK the XML FANBOYS!

Thank you,
Agent YES

17 May 2011 16:47

Comment now!
















Trackbacks