Miva-JSON conversion, revisited

Processing...
Miva-JSON conversion, revisited

In 2011, I wrote some functions for converting between Miva Script objects and JSON text. In the years since then, JSON has become more common for many types of data transfer and storage; it's not just for AJAX any more. It's replacing XML as a popular format for exchanging data over the Internet, and for storing it in a way that's compatible with many platforms and programs.

The Miva VM and compiler now support a built-in function, miva_json_decode(), for converting JSON to a Miva Script object. But there is no built-in function for going the other way, from Miva to JSON. So the function I wrote for that is still useful. Ray Yates and Timothy Bolton have made some bug fixes and improvements. A copy of the latest version is listed below.

My original article is still on-line at http://TheMagicM.com/jsonize.mvc. It includes a demo script so you can try the conversions yourself. It also has a link to download the source code for both the functions and the demo script.