Jayrock: JSON and JSON-RPC for .NET
Written by on May 1st, 2007 in Ajax News.
Jayrock is a modest and an open source implementation of JSON and JSON-RPC for the Microsoft .NET Framework, including ASP.NET. What’s so modest about it? Well, modest as in plain and basic and no work of genius.
A developer creates a helloworld.ashx that contains your server side logic:
C#:
-
-
<%@ WebHandler Class=”JayrockWeb.HelloWorld” %>
-
-
namespace JayrockWeb
-
{
-
using System;
-
using System.Web;
-
using Jayrock.Json;
-
using Jayrock.JsonRpc;
-
using Jayrock.JsonRpc.Web;
-
-
public class HelloWorld : JsonRpcHandler
-
{
-
[ JsonRpcMethod(”greetings”) ]
-
public string Greetings()
-
{
-
return “Welcome to Jayrock!”;
-
}
-
}
-
}
-
Then you can access the file asking for a proxy via helloworld.ashx?proxy and you will see a test page. From code you can now:
JAVASCRIPT:
-
-
var s = new HelloWorld();
-
-
alert(”sync:” + s.greetings());
-
-
s.greetings(function(response) {
-
alert(”async:” + response.result)
-
});
-
Nice and simple.
Source: Ajaxian
Original Article: http://ajaxian.com/archives/jayrock-json-and-json-rpc-for-net