ZF-5685: Zend_Json_Server does not respect the JSON RPC protocol

Issue Type: Improvement Created: 2009-02-04T03:15:37.000+0000 Last Updated: 2013-03-13T20:55:24.000+0000 Status: Open Fix version(s): - Next Mini Release ()

Reporter: Jean-Fran├žois (aikido) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend_Json_Server

  • FixForZF1.12.1
  • zf-crteam-review

Related issues: Attachments: - JsonServerNamedParameters.diff



I am French so, sorry for my bad English...

Zend_Json_Server does not respect the JSON RPC protocol. Here "", we can read this:

Procedure Call with named parameters:

--> {"jsonrpc": "2.0", "method": "subtract", "params": {"subtrahend": 23, "minuend": 42}, "id": 3} <-- {"jsonrpc": "2.0", "result": 19, "id": 3}

--> {"jsonrpc": "2.0", "method": "subtract", "params": {"minuend": 42, "subtrahend": 23}, "id": 4} <-- {"jsonrpc": "2.0", "result": 19, "id": 4}

Or the Zend_Json_Server does not make this. The order of the parameters is important but the protocol specify that the order of the parameters is not important (Look exeample)...

Zend_Json_Server must read the method arguments name for to sort the params correctly.


Posted by Matthew Weier O'Phinney (matthew) on 2009-02-04T12:08:33.000+0000

The 1.2 specification has never been officially adopted, and one area that has been especially contentious is the idea of parameter order. In fact, in the past week on the JSON-RPC lists, it was pointed out that supporting both unnamed and named parameters is something that's next to impossible to achieve in most languages. Zend_Json_Server, as a result, allows for either named keys, or an ordered array, and then passes them to the method -- and this is currently the recommendation that is being drafted in the 2.0 specification.

Posted by Matthew Weier O'Phinney (matthew) on 2009-02-04T12:39:50.000+0000

Actually... now that I look at the code again, I realize that named argument support is not currently implemented. I'm flagging this as an improvement.

Posted by Matthew Weier O'Phinney (matthew) on 2009-02-04T12:41:10.000+0000

Scheduling as "improvement", and marking as must have for 1.8.

Posted by Jean-Fran├žois (aikido) on 2009-02-05T01:01:35.000+0000

If I understood, for the moment, Zend_Json_Server can do:

--> {"jsonrpc": "2.0", "method": "subtract", "params": {"subtrahend": 23, "minuend": 42}, "id": 3} <-- {"jsonrpc": "2.0", "result": 19, "id": 3}

--> {"jsonrpc": "2.0", "method": "subtract", "params": [23, 42], "id": 3} <-- {"jsonrpc": "2.0", "result": 19, "id": 3}

In these cases, the order of the parameters is important and must be the same that the order of the method parameters. Zend_Json_Server is ok for these cases.

Now, Zend_Json_Server can not do that:

--> {"jsonrpc": "2.0", "method": "subtract", "params": {"minuend": 42, "subtrahend": 23}, "id": 4} <-- {"jsonrpc": "2.0", "result": 19, "id": 4}

Here, the order is not respected. It is this case which is problematic.

Are you agree with me?

Posted by Rob Olmos (ndrtek_rob) on 2009-06-11T16:57:37.000+0000

I have the same issue. Attached is a simple patch that corrects the issue in my simple usage.

I added throwing of an "exception" for invalid parameters but feel free to remove if deemed too much additional functionality for a minor release.

Thanks for the JSON Server module!

Rob Olmos Ender Technology Corp. <>

Posted by Rob Olmos (ndrtek_rob) on 2009-06-11T16:58:50.000+0000

Patch to correct the order of named parameters before dispatching.

Posted by -.- (campasau) on 2009-06-18T16:30:19.000+0000

Maybe batched requests can also be added?!

Posted by Marco Egli (egli) on 2009-07-07T00:53:03.000+0000

I'm using zf 1.8.4 an the bug is still open. Probably there is a need to change the "fix version" or to fix the issue. Thank you.

Posted by Matthew Weier O'Phinney (matthew) on 2009-07-07T04:49:22.000+0000

"next minor version" means the next minor version we release. We change it to the actual fix version once the issue is fixed.

I'll try and get it in for 1.9; patches are easier to accept when they include unit tests, however.

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.