I have a wordpress endpoint and have some json data. Unfortunately I don't know how to return this json data in the function. I tried json_decode but it returned nothing. Then the endpoint will work. If I use json_encode it returns the data but also includes newlines and other stuff. The problem seems to be with the syntax, since it's already a complete json that I have. How to return something already in json syntax?
add_action('wp_ajax_nopriv_inboundCall', 'testFunction'); add_action('wp_ajax_inboundCall', 'testFunction'); function testFunction() { echo json_decode('{ "testData": [ { "_id": "1", "name": "testName1" }, { "_id": "2", "name": "testName2" }, ], "testState": { "1": [ 1, 0 "2": [ 1, 0 ] } }'); die(); }