当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript lang.Json类代码示例

本文整理汇总了TypeScript中angular2/src/facade/lang.Json的典型用法代码示例。如果您正苦于以下问题:TypeScript Json类的具体用法?TypeScript Json怎么用?TypeScript Json使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Json类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

 it('should write all data into a file', inject([AsyncTestCompleter], (async) => {
      createReporter({
        sampleId: 'someId',
        descriptions: [{'a': 2}],
        path: 'somePath',
        metrics: {'script': 'script time'}
      })
          .reportSample(
              [mv(0, 0, {'a': 3, 'b': 6})],
              [mv(0, 0, {'a': 3, 'b': 6}), mv(1, 1, {'a': 5, 'b': 9})]);
      var regExp = /somePath\/someId_\d+\.json/g;
      expect(isPresent(RegExpWrapper.firstMatch(regExp, loggedFile['filename']))).toBe(true);
      var parsedContent = Json.parse(loggedFile['content']);
      expect(parsedContent).toEqual({
        'description':
            {'id': 'someId', 'description': {'a': 2}, 'metrics': {'script': 'script time'}},
        'completeSample': [
          {'timeStamp': '1970-01-01T00:00:00.000Z', 'runIndex': 0, 'values': {'a': 3, 'b': 6}}
        ],
        'validSample': [
          {'timeStamp': '1970-01-01T00:00:00.000Z', 'runIndex': 0, 'values': {'a': 3, 'b': 6}}, {
            'timeStamp': '1970-01-01T00:00:00.001Z',
            'runIndex': 1,
            'values': {'a': 5, 'b': 9}
          }
        ]
      });
      async.done();
    }));
开发者ID:LordBinary,项目名称:angular,代码行数:29,代码来源:json_file_reporter_spec.ts

示例2: function

 ListWrapper.forEach(entries, function(entry) {
   var message = Json.parse(entry['message'])['message'];
   if (StringWrapper.equals(message['method'], 'Tracing.dataCollected')) {
     ListWrapper.push(events, message['params']);
   }
   if (StringWrapper.equals(message['method'], 'Tracing.bufferUsage')) {
     throw new BaseException('The DevTools trace buffer filled during the test!');
   }
 });
开发者ID:SnackyPete,项目名称:angular,代码行数:9,代码来源:chrome_driver_extension.ts

示例3: reportSample

 reportSample(completeSample: MeasureValues[], validSample: MeasureValues[]): Promise<any> {
   var content = Json.stringify({
     'description': this._description,
     'completeSample': completeSample,
     'validSample': validSample
   });
   var filePath =
       `${this._path}/${this._description.id}_${DateWrapper.toMillis(this._now())}.json`;
   return this._writeFile(filePath, content);
 }
开发者ID:ProjectFrank,项目名称:angular,代码行数:10,代码来源:json_file_reporter.ts

示例4: it

 it('should write all data into a file', inject([AsyncTestCompleter], (async) => {
      createReporter({
        sampleId: 'someId',
        descriptions: [{'a': 2}],
        path: 'somePath',
        metrics: {'script': 'script time'}
      })
          .reportSample([mv(0, 0, {'a': 3, 'b': 6})],
                        [mv(0, 0, {'a': 3, 'b': 6}), mv(1, 1, {'a': 5, 'b': 9})]);
      var regExp = RegExpWrapper.create('somePath/someId_\\d+\\.json');
      expect(isPresent(RegExpWrapper.firstMatch(regExp, loggedFile['filename']))).toBe(true);
      var parsedContent = Json.parse(loggedFile['content']);
      expect(parsedContent)
          .toEqual({
            "description":
                {"id": "someId", "description": {"a": 2}, "metrics": {"script": "script time"}},
            "completeSample": [
              {
                "timeStamp": "1970-01-01T00:00:00.000Z",
                "runIndex": 0,
                "values": {"a": 3, "b": 6}
              }
            ],
            "validSample": [
              {
                "timeStamp": "1970-01-01T00:00:00.000Z",
                "runIndex": 0,
                "values": {"a": 3, "b": 6}
              },
              {
                "timeStamp": "1970-01-01T00:00:00.001Z",
                "runIndex": 1,
                "values": {"a": 5, "b": 9}
              }
            ]
          });
      async.done();
    }));
开发者ID:AsherBarak,项目名称:angular,代码行数:38,代码来源:json_file_reporter_spec.ts

示例5:

 return PromiseWrapper.resolve(this._events.map((event) => {
   return {
     'message': Json.stringify({'message': {'method': this._messageMethod, 'params': event}})
   };
 }));
开发者ID:844496869,项目名称:angular,代码行数:5,代码来源:chrome_driver_extension_spec.ts

示例6: function

 ListWrapper.forEach(entries, function(entry) {
   var message = Json.parse(entry['message'])['message'];
   if (StringWrapper.equals(message['method'], 'Timeline.eventRecorded')) {
     ListWrapper.push(records, message['params']['record']);
   }
 });
开发者ID:B-Thapa,项目名称:angular,代码行数:6,代码来源:ios_driver_extension.ts

示例7:

 entries.forEach(entry => {
   var message = Json.parse(entry['message'])['message'];
   if (StringWrapper.equals(message['method'], 'Timeline.eventRecorded')) {
     records.push(message['params']['record']);
   }
 });
开发者ID:1186792881,项目名称:angular,代码行数:6,代码来源:ios_driver_extension.ts

示例8:

 return PromiseWrapper.resolve(this._perfRecords.map(function(record) {
   return {
     'message': Json.stringify(
         {'message': {'method': 'Timeline.eventRecorded', 'params': {'record': record}}})
   };
 }));
开发者ID:1186792881,项目名称:angular,代码行数:6,代码来源:ios_driver_extension_spec.ts

示例9: it

 it("should return JSON-formatted string similar to Json.stringify", () => {
   var dream1 = normalize(pipe.transform(inceptionObj));
   var dream2 = normalize(Json.stringify(inceptionObj));
   expect(dream1).toEqual(dream2);
 });
开发者ID:B-Thapa,项目名称:angular,代码行数:5,代码来源:json_pipe_spec.ts

示例10: it

 it('should be able to recreate serializedHeaders', () => {
   let serializedHeaders = Json.stringify(headers);
   let parsedHeaders = Json.parse(serializedHeaders);
   let recreatedHeaders = new Headers(parsedHeaders);
   expect(Json.stringify(parsedHeaders)).toEqual(Json.stringify(recreatedHeaders));
 });
开发者ID:1186792881,项目名称:angular,代码行数:6,代码来源:headers_spec.ts


注:本文中的angular2/src/facade/lang.Json类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。