handle multiple json request

57 views
Skip to first unread message

s.am...@teravintech.com

unread,
Jul 19, 2013, 2:29:09 AM7/19/13
to jay...@googlegroups.com
how to handle multiple json request?

so there is a request like bellow:

{
  "id":3,
   "method":"echoTest",
   "params":{ "test" : "catty is here" }
},
{
  "id":4,
   "method":"echoTest",
   "params":{ "test" : "catty is here" }
}


and i want to get a result like bellow:

{
    "id":3,
    "result": { "test": "response catty is here"}
},
{
    "id":4,
    "result": { "test": "response catty is here"}
}

is Jayrock can handle this multiple? If yes, then how?

Thank you

Atif Aziz

unread,
Jul 19, 2013, 7:19:43 AM7/19/13
to jay...@googlegroups.com
“{…},{…}” is not valid JSON. I'm assuming you meant those to be in an array, as in “[{…},{…}]”. If that's the case, the following gist is a simple console program that demonstrates how you can execute batch requests and send their responses using Jayrock:
https://gist.github.com/atifaziz/6038424

- Atif



--
You received this message because you are subscribed to the Google Groups "Jayrock" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jayrock+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

s.am...@teravintech.com

unread,
Jul 20, 2013, 6:49:27 AM7/20/13
to jay...@googlegroups.com
oh you're right Atif, it should be [{…},{…}]
In your sample code, it has been determined that the request is an array json.

How if i want to make a dynamic one?
So it can determine whether the json is an array or not. If an array it will use your sample code, it not then it can use a default one.

Thanks you.

Atif Aziz

unread,
Jul 21, 2013, 6:26:39 PM7/21/13
to jay...@googlegroups.com
See the update to the earlier gist:

- Atif


s.am...@teravintech.com

unread,
Jul 22, 2013, 1:23:16 AM7/22/13
to jay...@googlegroups.com
Great..it works...
thank you so much Atif..
Reply all
Reply to author
Forward
0 new messages