from calvin.runtime.south.calvinlib import base_calvinlib_object
import json

class Json(base_calvinlib_object.BaseCalvinlibObject):
    """
    Functions for manipulating JSON.
    """

    init_schema = {
            "description": "setup json manipulation functions"
    }
    
    tostring_schema = {
        "description": "convert json structure into string",
        "type": "object"
        
    }
    
    fromstring_schema = {
        "description": "convert string representation of json structure into structure",
        "type": "string"
    }

    def init(self):
        pass
    
    def tostring(self, structure):
        return json.dumps(structure)

    def fromstring(self, string):
        return json.loads(string)


