Generate json dumped report for coveralls api.
558665
def create_report(self):
        """"""
        data = self.create_data()
        try:
            json_string = json.dumps(data)
        except UnicodeDecodeError as e:
            log.error('ERROR: While preparing JSON:', exc_info=e)
            self.debug_bad_encoding(data)
            raise

        log_string = re.sub(r'"repo_token": "(.+?)"',
                            '"repo_token": "[secure]"', json_string)
        log.debug(log_string)
        log.debug('==\nReporting %s files\n==\n', len(data['source_files']))
        for source_file in data['source_files']:
            log.debug('%s - %s/%s', source_file['name'],
                      sum(filter(None, source_file['coverage'])),
                      len(source_file['coverage']))
        return json_string
104685
def to_json(data):
    """"""
    return json.dumps(data, default=lambda x: x.__dict__, sort_keys=True, indent=4)
1299491
def outputjson(self, obj):
        
        self.header('Content-Type', 'application/json')
        self.outputdata(json.dumps(obj).encode('ascii'))
39921
def generate_api_for_source(self, source_fpath: str):
        """"""
        content = self.convert_content(source_fpath)
        if content is None:
            return

        dest_fpath = self.dest_fpath(source_fpath)
        self.create_fpath_dir(dest_fpath)

        with open(dest_fpath, 'w+') as dest_f:
            json.dump(content, dest_f, cls=DateTimeJsonEncoder)
354363
def run_json(self):
        
        checks = {}
        for file in self.files:
            try:
                results = self._check(file)
            except Error as e:
                checks[file] = {
                    "error": e.msg
                }
            else:
                checks[file] = {
                    "score": results.score,
                    "comments": results.comment_ratio >= results.COMMENT_MIN,
                    "diff": "<pre>{}</pre>".format("\n".join(self.html_diff(results.original, results.styled))),
                }

        json.dump(checks, sys.stdout, indent=4)
        print()
195317
def generate_coverage_report(coverage_xml, compare_branch,
                             html_report=None, css_file=None,
                             ignore_staged=False, ignore_unstaged=False,
                             exclude=None, src_roots=None):
    
    diff = GitDiffReporter(
        compare_branch, git_diff=GitDiffTool(), ignore_staged=ignore_staged,
        ignore_unstaged=ignore_unstaged, exclude=exclude)

    xml_roots = [cElementTree.parse(xml_root) for xml_root in coverage_xml]
    coverage = XmlCoverageReporter(xml_roots, src_roots)

    # Build a report generator
    if html_report is not None:
        css_url = css_file
        if css_url is not None:
            css_url = os.path.relpath(css_file, os.path.dirname(html_report))
        reporter = HtmlReportGenerator(coverage, diff, css_url=css_url)
        with open(html_report, "wb") as output_file:
            reporter.generate_report(output_file)
        if css_file is not None:
            with open(css_file, "wb") as output_file:
                reporter.generate_css(output_file)

    reporter = StringReportGenerator(coverage, diff)
    output_file = sys.stdout if six.PY2 else sys.stdout.buffer

    # Generate the report
    reporter.generate_report(output_file)
    return reporter.total_percent_covered()
790342
def save_to_json(self):
        """"""

        requestvalues = {
            'id': self.dataset,
            'publicationDate': self.publication_date.strftime('%Y-%m-%d'),
            'source': self.source,
            'refUrl': self.refernce_url,
        }        
        return json.dumps(requestvalues)
474279
def jsondump(model, fp):
    '''
    
    '''
    fp.write('[')
    links_ser = []
    for link in model:
        links_ser.append(json.dumps(link))
    fp.write(',\n'.join(links_ser))
    fp.write(']')
1101573
def post_report(coverage, args):
    """"""
    response = requests.post(URL, files={'json_file': json.dumps(coverage)},
                             verify=(not args.skip_ssl_verify))
    try:
        result = response.json()
    except ValueError:
        result = {'error': 'Failure to submit data. '
                  'Response [%(status)s]: %(text)s' % {
                      'status': response.status_code,
                      'text': response.text}}
    print(result)
    if 'error' in result:
        return result['error']
    return 0
334855
public function generatepage_json(){
		$status=200;
		foreach($this->rules as &$c){
			$this->positions[$c->position]=$c->output;
			if($c->status!=200){
				$status=$c->status;
				}
			}
		header('Content-type: text/json');
		if($status==403){
			header($_SERVER['SERVER_PROTOCOL'].' 403 Forbidden');
			}
		if($status==404){
			header($_SERVER['SERVER_PROTOCOL'].' 404 Page Not Found');
			}
		if($status==500){
			header($_SERVER['SERVER_PROTOCOL'].' 500 Server Error!');
			}
		echo $this->positions['content'];	
		}
940340
private function writeJsonFailureStream(
        CoverFishResult $coverFishResult,
        CoverFishPHPUnitTest $unitTest,
        CoverFishMessageError $mappingError,
        $coverLine
    ) {
        $this->jsonResult['errorCount'] = $coverFishResult->getFailureCount();
        $this->jsonResult['errorMessage'] = $mappingError->getMessageTitle();
        $this->jsonResult['errorCode'] = $mappingError->getMessageCode();
        $this->jsonResult['cover'] = $coverLine;
        $this->jsonResult['method'] = $unitTest->getSignature();
        $this->jsonResult['line'] = $unitTest->getLine();
        $this->jsonResult['file'] = $unitTest->getFile();
    }
185768
def generate(self, api):
        """"""
        with self.output_to_relative_path('ex1.out'):
            for namespace in api.namespaces.values():
                self.emit(namespace.name)
126621
def dump_json(testcase, json_file):
    
    logging.info("dump testcase to JSON format.")

    with io.open(json_file, 'w', encoding="utf-8") as outfile:
        my_json_str = json.dumps(testcase, ensure_ascii=ensure_ascii, indent=4)
        if isinstance(my_json_str, bytes):
            my_json_str = my_json_str.decode("utf-8")

        outfile.write(my_json_str)

    logging.info("Generate JSON testcase successfully: {}".format(json_file))
132483
def dump(self, obj, **kwargs):
        """"""
        self.obj = obj
        return super(JSONSchema, self).dump(obj, **kwargs)
1010381
function json (opts) {
  return {
    ...opts,
    headers: {
      ...opts.headers,
      'content-type': 'application/json'
    },
    body: JSON.stringify(opts.body)
  }
}
289997
def _create_json(self):
        
        data_json = {
            "rclass": "local",
            "key": self.name,
            "description": self.description,
            "packageType": self.packageType,
            "notes": "",
            "includesPattern": "**/*",
            "excludesPattern": "",
            "repoLayoutRef": self.repoLayoutRef,
            "dockerApiVersion": self.dockerApiVersion,
            "checksumPolicyType": "client-checksums",
            "handleReleases": True,
            "handleSnapshots": True,
            "maxUniqueSnapshots": 0,
            "snapshotVersionBehavior": "unique",
            "suppressPomConsistencyChecks": True,
            "blackedOut": False,
            "propertySets": [],
            "archiveBrowsingEnabled": self.archiveBrowsingEnabled,
            "yumRootDepth": 0,
        }
        return data_json
766348
def generate_sample_json():
    """"""

    check = EpubCheck(samples.EPUB3_VALID)
    with open(samples.RESULT_VALID, 'wb') as jsonfile:
        jsonfile.write(check._stdout)

    check = EpubCheck(samples.EPUB3_INVALID)
    with open(samples.RESULT_INVALID, 'wb') as jsonfile:
        jsonfile.write(check._stdout)