on 2016 Sep 14 6:04 PM
SQL Anywhere 16.0.0.1915
We are developing a JSON payload to be passed via a web service to an IOS application. It is simple enough to use the FOR JSON AUTO clause and I have obtained a variety of JSON selects. But our iPad developers have asked for a combined payload that would concatenate several selects into a single long varchar.
How to accomplish that escapes me.
Request clarification before answering.
Thanks for the ideas, looks like I will just "string" the data together. (Glad JSON is rather simple in that regard.)
The basic SELECT... FOR JSON is so easy, I was hoping for one more silver bullet: - SELECT * FROM A FOR JSON INTO ls_jsona; - SELECT * FROM B FOR JSON INTO ls_jsonb; - SELECT ls_jsona || ls_jsonb; OR: - SELECT * FROM A FOR JSON UNION ALL SELECT * FROM B FOR JSON;
Guess I'll have to actually do some work :-).
Thanks, Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you have create for example two JSON Strings in two variables.
set json1 = '{"Name": "Bob"};
set json1 = '{"Name": "Mary"};
You can combine these two JSON Objects in an array.
select string('[', json1, ',', json2, ']';
So instead of having different web service calls for different select statements you concatenate them in one variable and return the combine result as payload.
HTH
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Likewise you could create a JSON object instead of an array:
select string('{ "obj1" : ', json1, ', "obj2" : ', json2, '}';
User | Count |
---|---|
87 | |
9 | |
9 | |
8 | |
6 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.