Convert and print JSON.

    Argument:

        prs:  parser object of argparse
164011
def parse_show(prs):
    
    prs_show = prs.add_parser('show',
                              help='show converted JSON')
    set_option(prs_show, 'infile')
    prs_show.set_defaults(func=show)
959103
def json_dump(obj,       # type: Any
              fp,        # type: IO[str]
              **kwargs   # type: Any
             ):  # type: (...) -> None
    
    if six.PY2:
        kwargs['encoding'] = 'utf-8'
    json.dump(convert_to_dict(obj), fp, **kwargs)
197957
function Args() {
    if (argv._.length >= 1) {
        try {
            // Attempt to parse 1st argument as JSON string
            _.extend(this, JSON.parse(argv._[0]));
        } catch (err) {
            // Pass, we must be in the console so don't worry about it
        }
    }
}
927576
def pp_obj(obj, out_path=None, indent=4, sort_keys=False, ensure_ascii=False, default=None):
    
    rt = anyjson.dumps(obj, sort_keys=sort_keys, indent=indent, ensure_ascii=ensure_ascii,
                       separators=(',', ': '), default=default, namedtuple_as_object=False)
    # unicode_available
    if out_path is None:
        return rt
    else:
        with open(out_path, 'w') as out:
            out.write(rt)
1147052
def convert(args):
    
    p = OptionParser(convert.__doc__)
    p.set_phred()
    opts, args = p.parse_args(args)

    if len(args) != 1:
        sys.exit(not p.print_help())

    infastq, = args
    phred = opts.phred or str(guessoffset([infastq]))
    ophred = {"64": "33", "33": "64"}[phred]

    gz = infastq.endswith(".gz")
    outfastq = infastq.rsplit(".", 1)[0] if gz else infastq
    pf, sf = outfastq.rsplit(".", 1)
    outfastq = "{0}.q{1}.{2}".format(pf, ophred, sf)
    if gz:
        outfastq += ".gz"

    fin = "illumina" if phred == "64" else "sanger"
    fout = "sanger" if phred == "64" else "illumina"

    seqret = "seqret"
    if infastq.endswith(".gz"):
        cmd = "zcat {0} | ".format(infastq)
        cmd += seqret + " fastq-{0}::stdin fastq-{1}::stdout".\
                format(fin, fout)
    else:
        cmd = seqret + " fastq-{0}::{1} fastq-{2}::stdout".\
                format(fin, infastq, fout)

    sh(cmd, outfile=outfastq)

    return outfastq
1056879
def convert_args_to_dict(call, with_lambda=False):
    
    keys, values = list(), list()
    for arg in call.args:
        if type(arg) in [ast.Str, ast.Num]:
            arg_value = arg
        else:
        # if arg is not a string or a number, we use its source code as the key
            arg_value = astor.to_source(arg).strip('\n"')
            arg_value = ast.Str(str(arg_value))
        arg = make_lambda(arg) if with_lambda else arg
        keys.append(arg_value)
        values.append(arg)
    del call.args[:]
    call.args.append(ast.Dict(keys=keys, values=values))

    return call
212452
def __parse_args(cam_c):
    """"""
    user = None
    pswd = None
    name = None
    address = "{address}:{port}".format(**cam_c)
    if "user" in cam_c:
        user = cam_c["user"]
        if "pswd" in cam_c:
            pswd = cam_c["pswd"]
    if "name" in cam_c:
        name = cam_c["name"]
    return {"user": user, "pswd": pswd, "name": name, "address": address}
785174
def convert_json_file(obographfile, **args):
    
    f = open(obographfile, 'r')
    jsonstr = f.read()
    f.close()
    return convert_json_object(json.loads(jsonstr), **args)
1208335
def arg_string_from_dict(arg_dict, **kwds):
    
    # the filters dictionary
    filters = {
        **arg_dict,
        **kwds,
    }
    # return the correctly formed string
    return ", ".join("{}: {}".format(key, json.dumps(value)) for key,value in filters.items())
684713
def dump(*args, **kwargs):
    
    kwargs.update(dict(cls=NumpyEncoder,
                       sort_keys=True,
                       indent=4,
                       separators=(',', ': ')))
    return _json.dump(*args, **kwargs)
132820
function postProcess(json: string, printModule: string => string): string {
  return json.replace(
    /"@@MODULE_START@@(.*?)@@MODULE_END@@"/g,
    (_, moduleName) => printModule(moduleName),
  );
}
607241
def resp_json(resp):
    
    if isinstance(resp, flask.Response):
        if 400 <= resp.status_code < 600:
            msg = resp.status
            try:
                result = loads(resp.data.decode("utf-8"))
                if isinstance(result, str):
                    msg = "%s, %s" % (resp.status, result)
                else:
                    msg = "%s %s, %s" % (
                        resp.status_code, result["error"], result["message"])
            except Exception:
                pass
            raise requests.HTTPError(msg, response=resp)
        else:
            return loads(resp.data.decode("utf-8"))
    else:
        try:
            resp.raise_for_status()
        except requests.HTTPError as ex:
            # the response may contains {"error": "", "message": ""}
            # append error and message to exception if possible
            try:
                result = resp.json()
                ex.args += (result["error"], result["message"])
            except (ValueError, KeyError):
                pass
            raise
        return resp.json()
159567
def parse_command_line():
    """"""
    parser = argparse.ArgumentParser(
        prog='csp_pulsar_sender',
        description='Send fake pulsar data using ftp protocol.')
    parser.add_argument('config_file', type=argparse.FileType('r'),
                        help='JSON configuration file.')
    parser.add_argument('-v', '--verbose', help='Enable verbose messages.',
                        action='store_true')
    parser.add_argument('-p', '--print_settings', help='Print settings file.',
                        action='store_true')
    return parser.parse_args()
182387
def load_json(self):
        
        try:
            self.request.arguments = json.loads(self.request.body)
        except ValueError:
            msg = "Could not decode JSON: %s" % self.request.body
            self.logger.debug(msg)
            self.raise_error(400, msg)
917472
def output(s):
    
    p = Parser()
    t = ExpressionsTransformer()

    ast = p.parse(s)
    logging.debug(ast.pretty())
    print(ast.pretty())
    d = t.transform(ast)
    print(json.dumps(d, indent=4))
    return d
1287211
def to_json(value, **kwargs):
        
        b64rep = base64.b64encode(value.read())
        value.seek(0)
        jsonrep = '{preamble}{b64}'.format(
            preamble=PNG_PREAMBLE,
            b64=b64rep.decode(),
        )
        return jsonrep
441285
def _api_args_item(self, item):
        
        response.content_type = 'application/json; charset=utf-8'

        if item not in self.args:
            abort(400, "Unknown argument item %s" % item)

        try:
            # Get the JSON value of the args' dict
            # Use vars to convert namespace to dict
            # Source: https://docs.python.org/%s/library/functions.html#vars
            args_json = json.dumps(vars(self.args)[item])
        except Exception as e:
            abort(404, "Cannot get args item (%s)" % str(e))
        return args_json