UED - URL Encoded Data
Written by on March 15th, 2007 in Ajax News.
UED is a tiny library that takes a hash and converts it into a URL. Instead of passing a JSON string, for example, you could just construct a URL containing the transfer object.
Since it assumes you are making GET calls, RESTful design would suggest only using UED for non-destructive calls (i.e. calls that don’t change server state).
A hash is encoded like this:
JAVASCRIPT:
-
-
//The JS Array format of the example given above
-
var arr = {
-
‘name’:”Binny”,
-
‘year’:2007,
-
‘quote’:”Hello, World!”,
-
‘os’:[’Windows’,'Linux’,'Mac’],
-
’software’:{
-
‘editor’:”vi”,
-
‘audio’:”xmms”,
-
‘video’:”vlc”
-
}
-
}
-
var data = ued_encode(arr);
-
leading to a URL like this:
JAVASCRIPT:
-
-
http://www.example.com/get_data.php?name=Binny&year=2007&
-
quote=Hello%2C+World%21&os[]=Windows&os[]=Linux&os[]=Mac&
-
software[editor]=vi&software[audio]=xmms&software[video]=vlc
-
However, there are no server-side decoders as yet.
Source: Ajaxian
Original Article: http://ajaxian.com/archives/ued-url-encoded-data