function doFetch()
{
    header('Content-type: application/json');
    //Get IP address of client
    $ip = $_SERVER['REMOTE_ADDR'] ?: getenv('HTTP_CLIENT_IP') ?: getenv('HTTP_X_FORWARDED_FOR') ?: getenv('HTTP_X_FORWARDED') ?: getenv('HTTP_FORWARDED_FOR') ?: getenv('HTTP_FORWARDED');
    //Generate nonce (number used once) for allowing voting via Ajax
    $nonce = wp_create_nonce('nf_form_' + absint(4));
    //Get all votes
    $vote_recs = ninja_forms_get_all_subs(4);
    $votes = array();
    //Package vote info we care about
    foreach ($vote_recs as $vote_rec) {
        $vote_vals = unserialize($vote_rec['data']);
        $vote = array();
        foreach ($vote_vals as $vote_val) {
            switch ($vote_val['field_id']) {
                case 31:
                    $vote['mapid'] = intval($vote_val['user_value']);
                    break;
                case 32:
                    $vote['timestamp'] = intval($vote_val['user_value']);
                    break;
                case 33:
                    $vote['ip'] = $vote_val['user_value'];
                    break;
            }
        }
        if ($vote['ip'] == $ip) {
            $votes[] = $vote;
        }
    }
    $result = array('nonce' => $nonce, 'ip' => $ip, 'votes' => $votes);
    //Encodes with some extra fancy escaping as seen in ninja_forms_json_response in database.php in plugin folder
    echo json_encode($result, JSON_HEX_QUOT | JSON_HEX_TAG | JSON_PRETTY_PRINT);
}
<?php

/*
Template Name: Map Gallery Feed
*/
header('Content-type: application/json');
$subs = ninja_forms_get_all_subs(3);
$clean_subs = array();
//print_r(unserialize($subs[32]['data']));
foreach ($subs as $sub_text) {
    //Dig out and unpack the submission data
    $sub_id = $sub_text['id'];
    //Unique ID from database
    $sub_ser = $sub_text['data'];
    $sub = unserialize($sub_ser);
    //Image path
    $imgpath = "/wp-content/uploads/mapgallery/";
    //Create sanitized submission record for public
    $pubsub = array();
    foreach ($sub as $sub_value) {
        $pubsub['id'] = $sub_id;
        $pubsub['small'] = $imgpath . "small/" . $sub_id . '.jpg';
        $pubsub['medium'] = $imgpath . "medium/" . $sub_id . '.jpg';
        $pubsub['large'] = $imgpath . "large/" . $sub_id . '.jpg';
        $pubsub['orig'] = $imgpath . "orig/" . $sub_id . '.png';
        switch ($sub_value['field_id']) {
            case 30:
                $pubsub['title'] = $sub_value['user_value'];
                break;
            case 17:
                $pubsub['category'] = $sub_value['user_value'];