Creating JSON objects from ObjectScript objects
Say I have an ObjectScript object called Book. It has 2 properties title and author. It extends JSON.%Adaptor, so I can call book.%JSONExport() and get this output:
{ "title": "For Whom the Bell Tolls", "author": "Hemmingway" }
In my web service I want to have a search function that returns an array of Books along with the total number of responses, like this:
{
"results": 3,
"items": [
{ "title": "For Whom the Bell Tolls", "author": "Hemmingway" },
{ "title": "The Invisible Man", "author": "Ellison" },
{ "title": "Tender is the Night", "author": "Fitzgerald" }
]
}
What's the best way to do this? Can I export an ObjectScript object into a Dynamic Object?