Aussom Playground v0.8.2 | Aussom Docs
Input:
Aussom Code:
Output:

The Hello World

Here is the simplest example of an Aussom transform program. This is the obligatory hello world program.
class Hello {
    public main(payload) {
	return {
		message: "Hello World!"
	};
    }
}
			

More Involved Transform

This Aussom program represents a more advanced transform.
class NewExample {
    /**
     * Main is the entry point of the application.
     * @p payload is a string with the payload data.
     * @r A response string with the result.
     */
    public main(payload) {
	    // Convert from JSON string.
	    data = json.parse(payload);

	    // Attempt to run the transform. If there's a failure
	    // return the error message instead.
	    try {
    	    ret = this.processData(data);
    	} catch (e) {
    	    ret = "Error in 'processData': " + e.getText();
    	}

        return ret;
    }

    /**
     * Processes the provided data and performs the transform.
     * @p data is the parsed JSON data structure to process.
     * @r The transformed data.
     */
    private processData(data) {
        // Get filtered character quotes.
        quotes = [];
        for (quote : data.quotes) {
            if (quote.character == "Schultz" || quote.character == "Hogan") {
                quotes @= quote;
            }
        }

        // Create return object
        ret = {
            bestShowOfAllTime: data.showName,
            numberOfCharacters: #data.characters,
            numberOfSeasons: data.numberOfSeasons,
            quotes: quotes
        };

        return ret;
    }
}
			

OOP Example

This example uses object orientation to process and return the data. In this example we are just returning the object which is being rendered with toString(). If you'd rather see a JSON value you can use ret.toJson() or for pretty print you can wrap it like json.parse(ret.toJson()).
class OOPExample {
    /**
     * Main is the entry point of the application.
     * @p payload is a string with the payload data.
     * @r A response string with the result.
     */
    public main(payload) {
	    // Convert from JSON string.
	    data = json.parse(payload);

	    // Attempt to run the transform. If there's a failure
	    // return the error message instead.
	    try {
    	    ret = new show(data);
    	} catch (e) {
    	    ret = "Error in 'processData': " + e.getText();
    	}

        return ret;
    }
}

class show {
	public name = "";
	public characters = [];
	public numberOfSeasons = 0;
	public quotes = [];

	public show(data) {
		this.name = data.showName;
		this.numberOfSeasons = data.numberOfSeasons;
		this.characters = data.characters;

		// Filter quotes
		for (quote : data.quotes) {
			if (quote.character == "Schultz" || quote.character == "Hogan") {
				this.quotes @= quote;
			}
		}
    }
}