Fetch JSON string via Ajax, parse to HTML and append to the container.
512109
function(num) {
    if(loading) {
      // Avoid sending too many requests to get new cells.
      return;
    }
    var xhrRequest = new XMLHttpRequest();
    var fragment = document.createDocumentFragment();
    var cells = [];
    var images;
    xhrRequest.open('GET', 'json.php?n=' + num, true);
    xhrRequest.onreadystatechange = function() {
      if(xhrRequest.readyState == 4 && xhrRequest.status == 200) {
        images = JSON.parse(xhrRequest.responseText);
        for(var j = 0, k = images.length; j < k; j++) {
          var cell = document.createElement('div');
          cell.className = 'cell pending';
          cell.tagLine = images[j].title;
          cells.push(cell);
          front(cellTemplate, images[j], cell);
          fragment.appendChild(cell);
        }
        cellsContainer.appendChild(fragment);
        loading = false;
        adjustCells(cells);
      }
    };
    loading = true;
    xhrRequest.send(null);
  }
1179285
function getJSON(jsonUrl, done) {
    var parsedUrl = url.parse(jsonUrl);
    
    var options = {
        "host" : parsedUrl.hostname,
        "hostname": parsedUrl.hostname,
        "port" : parsedUrl.port || 80,
        "path" : parsedUrl.pathname,
        "method" : "GET",
        // "agent" : false,
    };
    
    debug && console.error("prepublish:getJSON('" + jsonUrl + "', done)");
    debug && console.error("options=" + util.inspect(options));
    var req = http.get(options, function (res) {
        debug && console.error("STATUS: " + res.statusCode);
        debug && console.error("HEADERS: " + JSON.stringify(res.headers));
        res.setEncoding('utf8');
        var data = '';
        res.on('data', function (chunk) {
            debug && console.error('getJSON: chunk="' + chunk + '"');
            data += chunk;
        });
        res.on('end', function() {
            debug && console.error('getJSON: end of request.');
            done(JSON.parse(data));
        });
    });

    req.on('error', function(error) {
        console.error("ERROR: " + error.message);
    });
}
830698
private static JSON toJSON( JSONString string, JsonConfig jsonConfig ) {
      return toJSON( string.toJSONString(), jsonConfig );
   }
573859
def handle_json_wrapper_GET(self, handler, parsed_params):
    """"""
    schedule = self.server.schedule
    result = handler(parsed_params)
    content = ResultEncoder().encode(result)
    self.send_response(200)
    self.send_header('Content-Type', 'text/plain')
    self.send_header('Content-Length', str(len(content)))
    self.end_headers()
    self.wfile.write(content)
1240854
def json(content, request=None, response=None, ensure_ascii=False, **kwargs):
    """"""
    if hasattr(content, 'read'):
        return content

    if isinstance(content, tuple) and getattr(content, '_fields', None):
        content = {field: getattr(content, field) for field in content._fields}
    return json_converter.dumps(content, default=_json_converter, ensure_ascii=ensure_ascii, **kwargs).encode('utf8')
1338887
function getJSON (url) {
  return new Promise((resolve, reject) => {
    var xhr = new XMLHttpRequest();
    xhr.open('get', url, true);
    xhr.onreadystatechange = function() {
      var status;
      var data;
      if (xhr.readyState === 4) { // `DONE`
        status = xhr.status;
        if (status === 200) {
          data = JSON.parse(xhr.responseText);
          resolve(data);
        } else {
          reject(status);
        }
      }
    };
    xhr.send();
  });
}
1032081
function returnJSON(finalResp, res) {
    if (JSONformat === 'JSON') {
      res.set('Content-Type', `application/json; charset=${encoding}`);
      res.json(finalResp);
    } else {
      res.set('Content-Type', `text/plain; charset=${encoding}`);
      res.send(JSON.stringify(finalResp));
    }
  }
135685
def fetch_json(self, method, url, data=None, expected_status_code=None):
        
        return self.fetch(method, url, data, expected_status_code).json()
53009
function toStringJSON (str) {
  if (isObject(str)) {
    return str
  } else if (isString(str)) {
    try {
      return JSON.parse(str)
    } catch (e) {}
  }
  return {}
}
838898
protected function parse()
    {
        $json = $this->httpResponse->json();

        $container = new Container();

        // Parse some basic info
        $container->setUuid($json['uuid']);
        $container->setUniqueName($json['unique_name']);

        // Parse links
        foreach ($json['linked_to_container'] as $rawLink) {
            $link = new ContainerLink(
                $rawLink['name'],
                $rawLink['from_container'],
                $rawLink['to_container'],
                $rawLink['endpoints']
            );

            $container->addLink($link);
        }

        $this->container = $container;
    }
944875
def append_json(
            self,
            obj: Any,
            headers: Optional['MultiMapping[str]']=None
    ) -> Payload:
        """"""
        if headers is None:
            headers = CIMultiDict()

        return self.append_payload(JsonPayload(obj, headers=headers))
104603
function getJSON (response) {
  return response.json().then((body) => {
    if (body.status !== 'ok') {
      throw error(response, body.status, body.data[0])
    }
    return body
  })
}
1027919
def render_json(result, cfg, **kwargs):
    
    result = json.loads(result.decode('utf-8'))
    head = result['head']
    if 'results' not in result:
        if 'boolean' in result:
            r = u'Result: {}'.format(result['boolean'])
        else:
            r = u'Unsupported result: \n' + unicode(result)
        return {'data': {'text/plain': r},
                'metadata': {}}

    vars = head['vars']
    nrow = len(result['results']['bindings'])
    if cfg.dis == 'table':
        j = json_iterator(vars, result['results']['bindings'], set(cfg.lan),
                          add_vtype=cfg.typ)
        n, data = html_table(j, limit=cfg.lmt, withtype=cfg.typ)
        data += div('Total: {}, Shown: {}', nrow, n, css="tinfo")
        data = {'text/html': div(data)}
    else:
        result = json.dumps(result,
                            ensure_ascii=False, indent=2, sort_keys=True)
        data = {'text/plain': unicode(result)}

    return {'data': data,
            'metadata': {}}
378197
def render_to_json(templates, context, request):
    
    html = render_to_string(
        templates,
        context=context,
        request=request
    )
    _json = json.dumps({
        "html": html
    })
    return HttpResponse(_json)
988600
def loadJson(self, data):
        """"""
        if not isinstance(data, dict):
            data = json.loads(data)
        self.__dict__.update(data)
        self.inflate() # restore objects from str values
        #if self.ports:  self._gotPorts = True
        return self
121004
function loadResourcesHT() {
  log( 'loadResourcesHT', 'resMap.length='+resMap.length );
  for( var x=0; x<resMap.length; x++ ) {
    var res = resMap[x];
    log( 'loadResourcesHT', res+" (type="+res[2]+")" );
    var divId = res[0];
    if ( res[2] == 'html' ) {
      loadResourcesHTajax( divId, res[1]+"/html" ); 
      $( "#"+divId ).addClass( "htmldiv" );
    } else if ( res[2] == 'raw' ) {
      loadResourcesHTajax( divId, res[1] );
    } else if ( res[2] == 'inner' ) {
      loadResourcesHTajax( divId, res[1] );
    } else {
      hook = getHookMethod( "loadResourcesHtml", res[2] );
      if ( hook != "" ) {
        log( 'loadResourcesHT', "hook="+hook );
        var param = {}; 
        if ( res[3] != null ) {
          param = res[3]; 
        }
        param.get = getUrlGETparams();
        hookCalls.push( hook+'( "'+divId+'", "'+res[1]+'", '+JSON.stringify( param )+' )'  );
        //eval( hook+"( divId, res[1], res[3] )" );
      }
    }
  }
  ajaxOngoing--;
}
437914
def as_json(context):
    """"""
    info = {
        'info': cgi.escape(pprint.pformat(context.context)),
    }
    return Response(content_type='application/json', body=json.dumps(info))