From: Paul R. <pa...@ma...> - 2012-11-11 01:14:17
|
On Thu, Nov 8, 2012 at 8:35 PM, Robert Munteanu <rob...@gm...>wrote: > On Wed, Nov 7, 2012 at 11:31 PM, Paul Richards <pa...@ma...> > wrote: > > I've just been having a look through the changes between 1.2.11 and > 1.2.12. > > > > There seems to be some things that appear to be "new"/unused features as > > opposed to minor bug fixes. > > > > For example, there's a new 'json' api that isn't used ( > > https://github.com/mantisbt/mantisbt/blob/master-1.2.x/core/json_api.php) > > within the core code. > > Yes, I've introduced to prototype its usage in a plugin [1] to provide > in-page validation . If I'm happy with how this turns out from a > UI/code point of view I will consider porting it to master-1.2.x . > > As I've mentioned before, I'm trying to unify the APIs behind a > service layer so that I can easily ( for users with Javacript enabled > ) provide in-page validation without requiring Javascript to be > available. > > If we are going to 'randomnly' add a json api, can I suggest we at least make it so it's something we might be able to build on in the future. For example, the json-rpc specification uses result and error->code/message as text identifiers - the following patch would make the json api follow this standard more: Or is there another standard that specificies the naming you picked? Paul @@ -88,26 +88,27 @@ function json_error_handler( $p_type, $p_error, $p_file, $p_line, $p_context ) { $t_error_type = ''; $t_error_description = $p_error; } json_output_raw(array( - 'status' => 'ERROR', - 'type' => $t_error_type, - 'contents' => $t_error_description + 'result' => null, + 'error' => array( 'name' => $t_error_type, + 'message' => $t_error_description) )); } /** * Outputs the specified contents inside a json response with OK status * * <p>Ensures that all necessary headers are set and terminates processing.</p> * @param string $contents The contents to encode */ - function json_output_response ( $contents = '') { + function json_output_response ( $contents = '', $id = 1 ) { json_output_raw( array( - 'status' => 'OK', - 'contents' => $contents + 'error' => null, + 'result' => $contents, + 'id' => $id ) ); } |