Replacing JSON libraries in Delphi rest servers

Source: Internet
Author: User

Http://blog.marcocantu.com/blog/json_libraries_delphi_rest.html

If you want to take advantage of jquery and some of its plug-ins in a Delphi Xe datasnap rest server application, you shoshould Replace the JSON processing library.

I 've been working a lot with Delphi Xe's datasnap rest server projects. I prepared a White Paper for Embarcadero, and some introductory videos, and will host a webinar for the company in a couple of weeks (details shoshould be made available soon ). i'm also
Developing a couple of real world projects and building an add-in Library (to be called "Delphi rest plus" or "dwarf, delphi web application rest framework "or SOE other name I still have to figure out ...). but that's for another post. before I get to
Actual topic, let me underline I like this new Delphi Xe architecture a lot, but it is only a good foundation you have to build more on top.

So, getting to this specific post, if you want to take advantage of jquery and some of its plug-ins in a Delphi datasxe rest server application, you shoshould Replace the JSON processing library that Embarcadero picked and that is causing lots of incompatibilities.
That is the json-min.js file, an open source library by Brenton Fletcher. The specific issues I 've had was with the "jquery validation plug-in 1.7" (http://bassistance.de/jquery-plugins/jquery-plugin-validation ).

As a replacer, I picked the "most official" javascript Parser for JSON, the public domain json2.js library you can find
Http://www.JSON.org/json2.js and see the description
Http://www.JSON.org/js.html. Now, of course, I also had to fix the some of the other JavaScript files generated by the datasnap rest Application Wizard in Delphi Xe. I don't think I can provide the actual
Files (since they are proprietary), only list the changes.

InServerfunctionsexecutor. jsYou have to change (around line 150) the first line below with the second:

   contentParam = contentParam.toJSONString(); // original   contentParam = JSON.stringify(contentParam); // new

And (around line 180) You have to fix:

   JSONResultWrapper = responseText.parseJSON(); // original   JSONResultWrapper = JSON.parse (responseText); // new

The first change (JSON. stringifyForTojsonstring) Has to be done also in the serverfunctionsinvoker. js file.

That's all for now, but stay tuned for other fixes and improvements to Delphi's rest support... and for the Embarcadero webinar.

PS. Still two more days only for the extra discount for delphi developer days Europe:
Http://www.delphideveloperdays.com /.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.