SQLAnywhere currently provides the ability to create a web service of TYPE 'JSON' that can return a JSON-serialized result set. Sample output of a web service returning "select * from people":
Is there any way to utilize the underlying JSON serialization function so that the JSON output string can be manipulated before it is returned from the web service? This would be very useful for creating JSON that is more than just the array notation representation of a result set, so that it can be easily consumed by popular JavaScript library components from ExtJS or jQuery. Example showing how a "JSON" function that operates in a similar manner to XMLELEMENT() might be used:
could produce something like (formatted for readability):
I'd be happy with just getting the result set array notation string and constructing the JSON manually though if the serialization function were exposed. |
While there is no native SQL support for doing this, you could make use of external environments and/or external functions. There are a whole bunch of existing libraries that generate and parse JSON that would work, depending on the language you choose. If you just want to generate it, JSON is a very simple format that could be built without too much trouble with SQL in a few stored procedures. Either way, you would need to make your service RAW and then build the JSON string yourself. |
There is currently no method (short of writing the SQL code to do it yourself) to generate JSON using the built-in code within SA ... but this feature is being consider for the next release. Meaning Innsbruck, or the release after that? By "next release" I mean the release after Innsbruck. Replies hidden
Do You have new information, when it is expected to release with a parser for the JSON-format (like openxml)?
(10 Jan '13, 09:19)
Ilia63
You may consider having a look at the SQL Anywhere 16 beta called "Nagano". I can't (and won't) tell whether there is support for anything you are looking for in v16 - but you may check for yourself.
(10 Jan '13, 09:43)
Volker Barth
|
I would like this feature too. A procudure/function would solve this issue too, is there any well tested function around here?