Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhnns/jsonpoo
Like JSONP, but better
https://github.com/jhnns/jsonpoo
Last synced: about 1 month ago
JSON representation
Like JSONP, but better
- Host: GitHub
- URL: https://github.com/jhnns/jsonpoo
- Owner: jhnns
- Created: 2012-12-21T14:16:59.000Z (about 12 years ago)
- Default Branch: master
- Last Pushed: 2016-05-17T16:04:28.000Z (over 8 years ago)
- Last Synced: 2024-10-14T12:45:21.076Z (2 months ago)
- Homepage:
- Size: 109 KB
- Stars: 9
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
JSONPoo
=======*Like JSONP, but better*
## Synopsis
**JSONPoo** is a brand-new data format based on [JSONP](http://en.wikipedia.org/wiki/JSONP). It is here to solve all problems with JSONP. Although there are currently no problems, it is always a good idea to have yet another data format.
## Concept
Currently it is really annoying that you have to pass the funciton name via the url, like `http://server2.example.com/Users/1234?jsonp=parseResponse`. This seems like a dirty hack and is not state of the art.
JSONPoo specifies that all callbacks have to be done via the `💩`-property of the `window`-object. The function is called with the first parameter being the url of the requested resource. All other parameters are optional and depend on the resource.
Within the `💩`-callback you can separate the incoming data by the url and proceed with the received data.
## Example
Inject into the head of the document:
```html
```
And the server will respond with:
```javascript
window["💩"]("http://server.example.com/users/1234", { name: "Hirsl", age: 25 });
```Now all you have to do is to define:
```javascript
window["💩"] = function (url) {
var args = Array.prototype.slice.call(arguments, 1);
switch (url) {
case "http://server.example.com/users/1234":
addUser.apply(null, args);
break;
...
}
};
```## Symbol
Please note, that the 💩-symbol is currently not allowed to be used in JavaScript-code. Therefore you have to escape it with brackets. A proposal for standardization is on the way.
The unicode+hex notation is: `U+1F4A9`. Until every keyboard has a 💩-symbol you may copy it from [here](http://unicodepooforyou.com/).