Aligning cJobject serialization with javaScript function namesIf you are not yet familiar with the cJobject, take a look at How to use cJobject , using javaScript like objects in VBA and jSon. If you have already been using cJobject for working with JSON and VBA, then you’ll be used to doing this.Create a JSON string from a cJobject s = j.serialize Create an object from a JSON string set j = new cjobject set j = j.init ( Nothing).deSerialize(s) {"_deserialization":{"key":100,"details":{"name":"fred","age":20},"list":["engineer","mathematician","cook" ]}} StandardizationWhereas different javaScript implementations used to have different ways of serializing JSON, they have now pretty much settled on JSON.parse for deSerialize and JSON.stringify () for serialize. So I’ve added a couple of things to cJobject to both simplify it and bring it into line with javaScript. you can now use either s=j.stringify() or s=JSONStringify(j) To make a VBA cJobect from jSon set j = JSONParse (s) Not only does this bring cJobject it more into line with javaScript , it also gets rid of the additional object level introduced by j.deserialize() The old methods will continue to work as before, so there is no need to change any existing code. Why not join our forum,follow the blog or follow me on twitter to ensure you get updates when they are available. See Excel, VBA , javaScript and Google for more topics |
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > excel to json and back >