How to use the @firebase/util.jsonEval function in @firebase/util

To help you get started, we’ve selected a few @firebase/util 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 firebase / firebase-js-sdk / packages / database / src / core / ReadonlyRestClient.ts View on Github external
xhr.onreadystatechange = () => {
          if (callback && xhr.readyState === 4) {
            this.log_(
              'REST Response for ' + url + ' received. status:',
              xhr.status,
              'response:',
              xhr.responseText
            );
            let res = null;
            if (xhr.status >= 200 && xhr.status < 300) {
              try {
                res = jsonEval(xhr.responseText);
              } catch (e) {
                warn(
                  'Failed to parse JSON response for ' +
                    url +
                    ': ' +
                    xhr.responseText
                );
              }
              callback(null, res);
            } else {
              // 401 and 404 are expected.
              if (xhr.status !== 401 && xhr.status !== 404) {
                warn(
                  'Got unsuccessful REST response for ' +
                    url +
                    ' Status: ' +
github firebase / firebase-js-sdk / packages / database / src / core / ReadonlyRestClient.ts View on Github external
xhr.onreadystatechange = () => {
          if (callback && xhr.readyState === 4) {
            this.log_(
              'REST Response for ' + url + ' received. status:',
              xhr.status,
              'response:',
              xhr.responseText
            );
            let res = null;
            if (xhr.status >= 200 && xhr.status < 300) {
              try {
                res = jsonEval(xhr.responseText);
              } catch (e) {
                warn(
                  'Failed to parse JSON response for ' +
                    url +
                    ': ' +
                    xhr.responseText
                );
              }
              callback(null, res);
            } else {
              // 401 and 404 are expected.
              if (xhr.status !== 401 && xhr.status !== 404) {
                warn(
                  'Got unsuccessful REST response for ' +
                    url +
                    ' Status: ' +
github firebase / firebase-js-sdk / packages / database / src / realtime / WebSocketConnection.ts View on Github external
private appendFrame_(data: string) {
    this.frames.push(data);
    if (this.frames.length === this.totalFrames) {
      const fullMess = this.frames.join('');
      this.frames = null;
      const jsonMess = jsonEval(fullMess) as object;

      //handle the message
      this.onMessage(jsonMess);
    }
  }
github firebase / firebase-js-sdk / packages / database / src / core / storage / DOMStorageWrapper.ts View on Github external
get(key: string): unknown {
    const storedVal = this.domStorage_.getItem(this.prefixedName_(key));
    if (storedVal == null) {
      return null;
    } else {
      return jsonEval(storedVal);
    }
  }