Completed code for processing JSON input via the REST API