I am trying to create a JSON string from a database using the Chilkat JSON object. I started with the example here: Create more Complex JSON Document. The JSON that I am trying create is a dictionary of arrays. If I modify the example code by removing the top 3 strings I get an object error. I am not sure the cause but I think it is something internal.
set json = Server.CreateObject("Chilkat_9_5_0.JsonObject") Response.Write json.Version <-- 18.104.22.168 ' success = json.AddStringAt(-1,"Title","The Cuckoo's Calling") ' success = json.AddStringAt(-1,"Author","Robert Galbraith") ' success = json.AddStringAt(-1,"Genre","classic crime novel") <-- allow any of these line and there is no error success = json.AddObjectAt(-1,"Detail") Set detail = json.ObjectAt(json.Size - 1) success = detail.AddStringAt(-1,"Publisher","Little Brown") <-- runtime error '800a01a8' Object required
Thanks! This was a bug -- if the JSON object is completely empty, and the very first item added is a sub-object, then the AddObjectAt returns false to indicate failure. (Internally, there is some initialization code that needed to be called but was not.)
This new build should fix it: