How to use the ms-rest.deserialize function in ms-rest

To help you get started, we’ve selected a few ms-rest 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 Azure / azure-sdk-for-node / runtime / ms-rest-azure / lib / azureServiceClient.js View on Github external
self.getLongRunningOperationResult(initialResult, options, (err, pollingResult) => {
      if (err) return callback(err);
      // Create Result
      let result = null;
      request = pollingResult.request;
      response = pollingResult.response;
      let responseBody = pollingResult.body;
      if (responseBody === '') responseBody = null;

      // Deserialize Response
      let parsedResponse = null;
      try {
        parsedResponse = JSON.parse(responseBody);
        result = JSON.parse(responseBody);
        if (parsedResponse !== null && parsedResponse !== undefined && options.deserializationMapperForTerminalResponse) {
          result = msRest.deserialize(options.deserializationMapperForTerminalResponse, parsedResponse, 'result');
        }
      } catch (error) {
        let deserializationError = new Error(`Error "${JSON.stringify(error, null, 2)}" occurred in deserializing the responseBody - "${responseBody}".`);
        deserializationError.request = msRest.stripRequest(request);
        deserializationError.response = msRest.stripResponse(response);
        return callback(deserializationError);
      }
      return callback(null, result, request, response);
    });
  });