There is already very similar plugin. This looks like rewrite ofhttp://wordpress.org/plugins/json-api/