JSON.tryParse with Promise

Wednesday, September 9, 2015

JSON.parse is a method you must have used one or twice. And you must remember that it raises exception, as almost every parsing string in case the string comes in a wrong format. So, how about having a function that returns promise, so you can safely parse JSON's  and receive its result on the promise's "then" method. Here's some small code example: JSON.tryParse('{"a" : 1}').then(function(result) { //do something with the result }, function(error) { //do something with the error }); And here's the link to its gist: https://gist.github.com/ranwahle/2d38730af21909dd70a2
no comments

AJAX and Dates

Saturday, October 25, 2008

AJAX and Dates While AJAX in general, and Data-Services in particular becomes more and more in use, you may encounter a problem of sending / receiving dates when you don't usually share the same Time Zone settings.   Dates between services When sending dates over soap the date is serialized with the date and it's time zone (The GMT +/- # part which comes straight after the date itself). When consuming a service through .Net application you won't noticeany difference, That's mainly because it  is being translated to your local time. What's happens "behind the scene" is that...
no comments

Sending complex typed data from web service to SilverLight client – Part III

Monday, August 4, 2008

Sending complex typed data from web service to SilverLight client - Part IIIOn my previous post I discussed the JavaScript mediator part, Here I'll sum this part which is Serialize the object for the SilverLightcomponent and operate method inside it to bind the data. Step 5 - Serialize the data for the SilverLight componentAnd here is the code converting the objects function onGettingAllEmployeesSuccess(result){ var slEmployees = new Array(result.length); for (var index = 0; index <result.length; index++) { var newEmployee = ...
no comments

Sending complex typed data from web service to SilverLight client – Part II

Thursday, July 31, 2008

Sending complex typed data from web service to SilverLight client - Part II On my previous post I've explained the first steps of creating the service and methods on the server side, and the client corresponding objects in the Silverlight project. Here I'll go further on the JavaScript mediator side. After making the Web method for getting the employee, we have to call it from out JavaScript mediator,  convert the objects received from the server to the SilverLight corresponding ones, and serialize the objects for our SilverLight component. Step 3 - Create the JavaScript mediator: Here is the code for the service call...
no comments

Sending complex typed data from web service to SilverLight client – Part I

Tuesday, July 29, 2008

Sending complex typed data from web service to SilverLight client - Part I In this post I'll explain in how to send complex typed data between web service and SilverLight  client code. In order to avoid security issues I'll use JavaScript as mediator between my server code and SilverLight code.   First - Let's have a look at a solution contains web server side code with all layers (Presentation that will host silverlight  control , BL, DAL, Structures) and another SilverLight project Now, leaving out all server-side lower layers and focusing on presentation layer and SilverLight code, let's have a look...
2 comments