Getting Java, C# and Perl to speak the same language (with JSON)

Using JSON examples in Java, C# and Perl to understand cross-platform architecture.

I’ve been thinking a lot about architecture lately. It’s partially because Jenny and I are going to do our Beautiful Teams talk at the ITARC 2009 conference next week. But it’s also because I’ve been writing a lot of code lately that’s gotten me thinking about some architecture problems that I find pretty interesting. One of the problems I’ve been contending with has been how to efficiently get complex data structures to stay intact while being sent across various pipes and between different platforms. It’s a really interesting topic, one that’s really given me some new insights into some pretty fascinating questions about the nature of data, and where the data ends and the container begins.

I spend a lot of my time training developers, helping junior and intermediate programmers learn the skills and concepts they need to become senior developers. So whenever I run across a topic like this, I always ask myself, “Is there something an intermediate — or even a novice — programmer can learn here?” I’ve spent a lot of my career helping junior programmers become senior developers and architects. (That’s why we wrote Head First C#!) If you’re a developer who’s looking to expand your horizons a bit, this is definitely an area that can help you do that.


Continue reading »


How to post a form by Json without page reloading?

Javascript:

function submitAddLink( )
{
print(‘<img src=”{URL_IMAGES}loading.gif” />’, ‘processAddLink’);

var oForm = document.frmAddLink;

oXMLHttp = checkXMLHTTP();
var setRequest = typeof(oXMLHttp.setRequestHeader);
if ( oXMLHttp && setRequest!=”undefined” )
{
var myQuery = ’sAction=detail’;
if(oForm.elements.length > 0){
for(var iElement in oForm.elements){
myQuery = myQuery + ‘&’ + oForm.elements[iElement].name + ‘=’ + oForm.elements[iElement].value;
}
}

orderPost( oXMLHttp, “index.php”, myQuery, HTTPsubmitAddLink, true );
}
}
function HTTPsubmitAddLink()
{
if ( typeof(oXMLHttp)===’undefined’ )
return;

// Return status of XMLHttp object
if ( oXMLHttp.readyState==4 )
{
// if oXMLHttp.status is OK
if ( oXMLHttp.status==200 )
{
sRes = ((oXMLHttp.responseText));
oJson = sRes.parseJSON();
var sTr = oJson['BODY']['RES'];
// Call Hide Form Function Here
// HideAddLink();
}

if ( oXMLHttp.status==404)
{
alert(“Page not found”);
}
}
return;
}

HTML:

<!– BEGIN: ADDLINK –>
<form name=”frmAddLink” action=”" method=”post”>
<input type=”hidden” name=”task” value=”SubmitAddLink” />
<table width=”100%” border=”0″ class=”formBlock”>
<tr>
<td><span class=”normal”><strong>{LANG_HEADER.url}:</strong></span></td>
</tr>
<tr>
<td><input name=”link_url” id=”link_url” type=”text” size=”50″ maxlength=”255″ value=”{write.link_url}” /></td>
</tr>
<tr>
<td><span class=”normal”><strong>{LANG_HEADER.describe_link}:</strong></span></td>
</tr>
<tr>
<td><input name=”link_description” id=”link_description” type=”text” size=”50″ maxlength=”255″ value=”{write.link_description}” /></td>
</tr>
<tr>
<td><span class=”normal”><strong>{LANG_HEADER.type}:</strong></span></td>
</tr>
<tr>
<td><select name=”lt_id”>
<!– BEGIN: lts –>
<option value=”{lts.lt_id}”>{lts.lt_name}</option>
<!– END: lts –>
</select>
</td>
</tr>
<tr>
<td>
<div id=”processAddLink”></div>
<input id=”save” name=”save” type=”button” value=”{LANG_FORM.save}” class=”button” onclick=”javascript: submitAddLink( ‘{venue_id}’ ); showLinksBlock( ‘{venue_id}’ ); cancelAddLink(); ” /> <input id=”cancel” name=”cancel” type=”button” value=”{LANG_FORM.cancel}” class=”button” onclick=”javascript: cancelAddLink();” />

</td>
</tr>
</table>
</form>
<!– END: ADDLINK –>