How to use json-bigint - 10 common examples

To help you get started, we’ve selected a few json-bigint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github NaturalHistoryMuseum / ckanext-nhm / ckanext / nhm / theme / fanstatic / scripts / apps / vfactor-iiif / src / App.vue View on Github external
).then(response => {
                        // use JSONbig to make sure we parse the enormous ints in the after correctly
                        const jsonData = parseJSON(response.data);

                        // grab the after and total
                        this.after = jsonData.result.after;
                        this.total = jsonData.result.total;

                        // then update the records
                        this.onRecordsChange(jsonData.result.records, isMoreRequest);
                    }).catch(error => {
                        console.log(error);
github node-webot / co-wechat-api / lib / api_common.js View on Github external
}

    var res = await httpx.request(url, options);
    if (res.statusCode < 200 || res.statusCode > 204) {
      var err = new Error(`url: ${url}, status code: ${res.statusCode}`);
      err.name = 'WeChatAPIError';
      throw err;
    }

    var buffer = await httpx.read(res);
    var contentType = res.headers['content-type'] || '';
    if (contentType.indexOf('application/json') !== -1) {
      var data;
      var origin = buffer.toString();
      try {
        data = JSONbig.parse(replaceJSONCtlChars(origin));
      } catch (ex) {
        let err = new Error('JSON.parse error. buffer is ' + origin);
        err.name = 'WeChatAPIError';
        throw err;
      }

      if (data && data.errcode) {
        let err = new Error(data.errmsg);
        err.name = 'WeChatAPIError';
        err.code = data.errcode;

        if ((err.code === 40001 || err.code === 42001) && retry > 0 && !this.tokenFromCustom) {
          // 销毁已过期的token
          await this.saveToken(null);
          let token = await this.getAccessToken();
          let urlobj = liburl.parse(url, true);
github dialogflow / dialogflow-nodejs-client / samples / facebook / src / app.js View on Github external
app.post('/webhook/', (req, res) => {
    try {
        const data = JSONbig.parse(req.body);

        if (data.entry) {
            let entries = data.entry;
            entries.forEach((entry) => {
                let messaging_events = entry.messaging;
                if (messaging_events) {
                    messaging_events.forEach((event) => {
                        if (event.message && !event.message.is_echo) {

                            if (event.message.attachments) {
                                let locations = event.message.attachments.filter(a => a.type === "location");

                                // delete all locations from original message
                                event.message.attachments = event.message.attachments.filter(a => a.type !== "location");

                                if (locations.length > 0) {
github gridgain / gridgain / modules / web-console / frontend / app / modules / agent / decompress.worker.js View on Github external
onmessage = function(e) {
    const data = e.data;

    const binaryString = atob(data.payload); // Decode from BASE64

    const unzipped = pako.inflate(binaryString, {to: 'string'});

    const res = data.useBigIntJson
        ? bigIntJSON({storeAsString: true}).parse(unzipped)
        : JSON.parse(unzipped);

    postMessage(_.get(res, 'result', res));
};
github liquality / chainabstractionlayer / dist / index.esm.js View on Github external
// Deliberately forget the last sent value so that we don't
        // accidentally pass it on to the delegate.
        this.arg = undefined;
      }

      return ContinueSentinel;
    }
  };
})(
  // In sloppy mode, unbound `this` refers to the global object, fallback to
  // Function constructor if we're in global strict mode. That is sadly a form
  // of indirect eval which violates Content Security Policy.
  (function() { return this })() || Function("return this")()
);

var _JSONBigInt = JSONBigInt({ storeAsString: true, strict: true }),
    parse = _JSONBigInt.parse;

function prepareRequest(_ref) {
  var method = _ref.method,
      params = _ref.params;

  return JSON.stringify({
    id: Date.now(),
    method: method,
    params: params
  });
}

function praseResponse(body, headers) {
  if (typeof body === 'string' && headers['content-type'] !== 'application/json') {
    throw new Error(body);
github fireworq / fireworqonsole / client / queue-list / Container.tsx View on Github external
public async asyncGetQueueStats(): Promise {
    try {
      const path = '/api/queues/stats';
      const response: Response = await fetch(path, {
        method: 'GET'
      });
      if (response.ok) {
        const stats = snakeToCamel(JSON.parse(await response.text()));
        this.dispatch(statsListRetrieved(stats as StatsList));
      } else {
        throw new Error(`Request to ${path} failed with status code ${response.status}`);
      }
    } catch (err) {
      console.error(err);
    }
  }
github fireworq / fireworqonsole / client / version-list / Container.tsx View on Github external
public async asyncGetNodeVersions(): Promise {
    this.dispatch(fetchStarted());
    try {
      const path = '/api/versions';
      const response: Response = await fetch(path, {
        method: 'GET'
      });
      if (response.ok) {
        const versions = JSON.parse(await response.text());
        this.dispatch(nodeVersionsRetrieved(versions as NodeVersion[]));
      } else {
        throw new Error(`Request to ${path} failed with status code ${response.status}`);
      }
    } catch (err) {
      console.error(err);
    } finally {
      this.dispatch(fetchFinished());
    }
  }
github hjespers / node-red-contrib-teslams / teslams / teslams.js View on Github external
teslams.all( { email: tesla_email, password: tesla_password }, function ( error, response, body ) {
                    var data, vehicle, e;
                    //check we got a valid JSON response from Tesla
                    //util.inspect( 'response is: \n' + response );
                    try { 
                        data = JSONbig.parse(body); 
                    } catch(err) { 
                        console.log('[teslams] Telsa login error: ' + err);
                        outmsg.payload = err;
                        node.send(outmsg);
                    }
                    //check we got an array of vehicles and get the first one
                    if (!util.isArray(data.response)) {
                        util.inspect( data.response );                        
                        e = new Error('expecting an array from Tesla Motors cloud service');
                        util.log('[teslams] ' + e);
                        outmsg.payload = e;
                        node.send(outmsg);
                    } else {
                        vehicle = data.response[0];
                        //check the vehicle has a valid id
                        if (vehicle === undefined || vehicle.id === undefined) {
github fireworq / fireworqonsole / client / new-job / Container.tsx View on Github external
public async asyncPutNewJob(job: any, callback?: () => void): Promise {
    this.dispatch(saveStarted());
    let queueName: string | undefined;
    try {
      const path = '/api/job/' + encodeURIComponent(job.category);
      const response: Response = await fetch(path, {
        method: 'POST',
        body: JSON.stringify(job)
      });
      if (response.ok) {
        const job = snakeToCamel(JSON.parse(await response.text()));
        queueName = job.queueName as string;
        this.dispatch(saveFinished(queueName));
        if (callback !== undefined) callback();
        history.push(pathQueueJobs(queueName));
      } else {
        this.dispatch(saveFinished(undefined));
        throw new Error(`Request to ${path} failed with status code ${response.status}`);
      }
    } catch (err) {
      console.error(err);
    }
  }
}
github fireworq / fireworqonsole / client / routing / Container.tsx View on Github external
public async asyncPutRouting(jobCategory: string, queueName: string): Promise {
    this.dispatch(saveStarted(jobCategory));
    try {
      const path = '/api/routing/' + encodeURIComponent(jobCategory);
      const response: Response = await fetch(path, {
        method: 'PUT',
        body: JSON.stringify({ queue_name: queueName })
      });
      if (!response.ok) {
        throw new Error(`Request to ${path} failed with status code ${response.status}`);
      }
    } catch (err) {
      console.error(err);
    } finally {
      this.dispatch(saveFinished(jobCategory, queueName));
      history.push('/routing/' + encodeURIComponent(jobCategory));
      this.asyncGetRouting(jobCategory);
    }
  }

json-bigint

JSON.parse with bigints support

MIT
Latest version published 4 years ago

Package Health Score

69 / 100
Full package analysis