close

  
<p> // Utillity functions.
// Author: Arthur van Hoff

// Generate an XML begin and end tag.

function xml_begin(ctype) {
    acre.start_response(200, {"Content-Type":ctype});
    acre.write('');
    return "";
}

function xml_end()
{
    //acre.exit();
    return "";
}

// HTML encode an object, use with acre:atts

function isArray(obj) {
    return obj != null &amp;&amp; obj.constructor == Array;
}

// Encode/Decode JSON or RISON

var rison = acre.require('rison');
rison.rison.parser.WHITESPACE = " \t\n\r\f";

function decode(str)
{
    try {
        // first try rison
        return rison.rison.decode(str);        
    } catch (e) {
        try {
            // then try JSON
            return JSON.parse(str);
        } catch (ee) {
            throw e;
        }
    }
}

function encode(obj)
{
    return rison.rison.encode(obj);
}


 </p>

Comments

Hide