Convert Event (or other) object to JSON in Widget API?

In my custom widget I have created and gotten a hold of a reference to an Event object.  My question is how can I marshall this to object into a JSON object.  Is there something built in for this, or do I need to create my own marshaller of sorts with Velocity code?

And what about other object types (Thread, Wiki Page, etc.)?

And, if I needed to roll my own, are there any utilities in the widget API to properly escape string values as JSON?

Thanks.

Parents
  • There is not a built-in object-to-JSON serializer, instead, format the object using Velocity:

    $core_v2_page.SetContentType('application/json')
    
    {
        "Property":"$core_v2_encoding.JavascriptEncode($object.Property)",
        "Property2":"$core_v2_encoding.JavascriptEncode($object.Proeprty2)"
    }

    This allows you to include only the data you care about.

Reply
  • There is not a built-in object-to-JSON serializer, instead, format the object using Velocity:

    $core_v2_page.SetContentType('application/json')
    
    {
        "Property":"$core_v2_encoding.JavascriptEncode($object.Property)",
        "Property2":"$core_v2_encoding.JavascriptEncode($object.Proeprty2)"
    }

    This allows you to include only the data you care about.

Children
No Data