JSONFilter

@method JSONFilter
@param {String} output the final build file produced by ethdeploy
@return {String} parsedOutput parsed output
556218
function JSONFilter(contractProperties = ['address', 'interface', 'bytecode', 'transactionObject', 'inputs']) {
  const self = this;
  self.process = ({ output }) => {
    const jsonObject = JSON.parse(output);
    const outputObject = Object.assign({});

    Object.keys(jsonObject).forEach((environmentName) => {
      outputObject[environmentName] = Object.assign({});

      Object.keys(jsonObject[environmentName]).forEach((contractName) => {
        outputObject[environmentName][contractName] = Object.assign({});

        Object.keys(jsonObject[environmentName][contractName]).forEach((contactProperty) => {
          if (contractProperties.indexOf(contactProperty) !== -1) {
            outputObject[environmentName][contractName][contactProperty] = jsonObject[environmentName][contractName][contactProperty];
          }
        });
      });
    });

    return JSON.stringify(outputObject);
  };
}
191179
def get_output(self):
        """"""
        logger.info("Getting outputs.")
        # Get the set of prefixes (each will correspond to three json files.)
        json_files = glob.glob(path.join(self.output_dir, '*.json'))
        json_prefixes = set()
        for json_file in json_files:
            # Remove .uaz.<subfile type>.json
            prefix = '.'.join(path.basename(json_file).split('.')[:-3])
            json_prefixes.add(path.join(self.output_dir, prefix))

        # Join each set of json files and store the json dict.
        for prefix in json_prefixes:
            base_prefix = path.basename(prefix)
            if base_prefix.isdecimal():
                base_prefix = int(base_prefix)
            elif base_prefix in self.id_maps.keys():
                base_prefix = self.id_maps[base_prefix]
            try:
                content = self._join_json_files(prefix, clear=True)
            except Exception as e:
                logger.exception(e)
                logger.error("Could not load result for prefix %s." % prefix)
                content = None
            self.add_result(base_prefix, content)
            logger.debug('Joined files for prefix %s.' % base_prefix)
        return self.results
877244
def _parse(jsonOutput):
    '''
    
    '''
    parsed={}
    if not jsonOutput:
        return parsed
    
    parsed["status"] = jsonOutput[0]
    if jsonOutput[1] == None or jsonOutput[1] == "":
        return parsed
    realJson = json.loads(jsonOutput[1])

    content = ""
    for js in realJson:
        if "X-TIKA:content" in js:
            content += js["X-TIKA:content"]

    if content == "":
        content = None

    parsed["content"] = content
    parsed["metadata"] = {}

    for js in realJson:
        for n in js:
            if n != "X-TIKA:content":
                if n in parsed["metadata"]:
                    if not isinstance(parsed["metadata"][n], list):
                        parsed["metadata"][n] = [parsed["metadata"][n]]
                    parsed["metadata"][n].append(js[n])
                else:
                    parsed["metadata"][n] = js[n]

    return parsed
759729
def format_output(result, format)
      case format
      when :json
        JSON.pretty_generate(result)
      when :yaml
        YAML.dump(result)
      when :text
        result = result.keys if result.respond_to?(:keys)
        result.join(" ")
      else
        raise ArgumentError, "Unknown output format #{format}"
      end
    end
608332
function convertAbcToJson(input) {
  var outputData = {};
  var parser = new Parser();
  parser.parse(input);
  var tune = parser.getTune();
  outputData = createJsonFromLines(tune);
  outputData.id = getJsonId(input);

  return JSON.stringify(outputData);
}
365453
def output_json(gandi, format, value):
    
    if format == 'json':
        gandi.echo(json.dumps(value, default=date_handler, sort_keys=True))
    elif format == 'pretty-json':
        gandi.echo(json.dumps(value, default=date_handler, sort_keys=True,
                              indent=2, separators=(',', ': ')))
964248
function switchOutput(type, json) {
  if (type[0] === '.') type = type.slice(1);
  var result = '';

  switch (type) {
    case 'md':
      result = ''
        + '\n```json\n'
        + json
        + '\n```\n';
      break;
    case 'html':
      result = ''
        + '<div class="highlight highlight-json">\n'
        + '<pre><code>\n'
        + json
        + '</code></pre>'
        + '</div>';
      break;
    default: {
      result = json;
      break;
    }
  }
  return result;
}
423784
function parseLdOutput(output) {
    const libraryList = output.split('\n').filter(ln => ln.includes('=>'));

    const result = {};
    libraryList.forEach(s => {
        const [name, _, libPath] = s.trim().split(' ');
        result[name] = libPath;
    });

    return result;
}
678181
function htmlToJsonController (fileContents, filePath, output, p) {

    var matches;
    var includePaths = false;

    while (matches = _DIRECTIVE_REGEX.exec(fileContents)) {

        var relPath     = path.dirname(filePath),
            fullPath    = path.join(relPath,  matches[3].replace(/['"]/g, '')).trim(),
            jsonVar     = matches[2],
            extension   = matches[3].split('.').pop();

        var fileMatches = [];

        if (p.includePaths) {

            if (typeof p.includePaths == "string") {
                // Arrayify the string
                includePaths = [params.includePaths];
            }else if (Array.isArray(p.includePaths)) {
                // Set this array to the includepaths
                includePaths = p.includePaths;
            }

            var includePath = '';

            for (var y = 0; y < includePaths.length; y++) {

                includePath = path.join(includePaths[y], matches[3].replace(/['"]/g, '')).trim();

                if (fs.existsSync(includePath)) {

                    var globResults = glob.sync(includePath, {mark: true});
                    fileMatches = fileMatches.concat(globResults);

                }

            }

        } else {

            var globResults = glob.sync(fullPath, {mark: true});
            fileMatches = fileMatches.concat(globResults);

        }

        try {

            fileMatches.forEach(function(value){

                var _inc = _parse(value);

                if (_inc.length > 0) {

                    var ind = (jsonVar.trim() == '*') ? indName(value) : jsonVar;
                    output[ind] = _inc;
                }
            })

        } catch (err) {
            console.log(err)
        }

    }
}
660417
def convert(self, json, fout):
        
        self.build_markdown_body(json)  # create the body
        self.build_header(json['name'])  # create the md header
        self.build_output(fout)
681445
def _api_convert_output(return_value):
    
    content_type = web.ctx.environ.get('CONTENT_TYPE', 'text/json')

    if "text/json" in content_type:
        web.header('Content-Type', 'text/json; charset=utf-8')
        return json.dumps(return_value)
    if "text/html" in content_type:
        web.header('Content-Type', 'text/html; charset=utf-8')
        dump = yaml.dump(return_value)
        return "<pre>" + web.websafe(dump) + "</pre>"
    if "text/yaml" in content_type or \
                    "text/x-yaml" in content_type or \
                    "application/yaml" in content_type or \
                    "application/x-yaml" in content_type:
        web.header('Content-Type', 'text/yaml; charset=utf-8')
        dump = yaml.dump(return_value)
        return dump
    web.header('Content-Type', 'text/json; charset=utf-8')
    return json.dumps(return_value)
1341334
function writeFiles(result) {
  var json = {};
  json.name = "Sample Markade Site";
  json.directories = {
    "output": path.relative(result.root, result.output),
    "template": path.relative(result.root, result.template),
    "data": path.relative(result.root, result.data)
  };
  json.templates = {
    "index.pug": ["index.md", "second.md"]
  };

  var filePath = path.resolve(result.root, "markade.js");
  return util.writefile(filePath, "module.exports = " + JSON.stringify(json, null, 2));
}
577827
async function generateJson(options, generatorResult) {
  const jsonPath = (
    options.jsonPath ||
    `${ path.join(options.outputDir, '/' + options.fontName) }.json`
  )

  const css = generatorResult.generateCss()
  let map = {}

  css.replace(CSS_PARSE_REGEX, (match, name, code) => map[name] = code)

  await fsAsync.writeFile(jsonPath, JSON.stringify(map, null, 4))
}
592252
function encodeOutputToJson(output) {
    var book = output.getBook();
    var generator = output.getGenerator();
    var options = output.getOptions();

    var result = encodeBook(book);

    result.output = {
        name: generator
    };

    result.options = options.toJS();

    return result;
}
916451
function json (program, callback) {
    var formatterRedux = formatter(jsonRedux())
    parse(program.stdin, program.stderr, printer(formatterRedux, program.stdout, program.stderr), callback)
}
782963
private static String formatOutput(String js, boolean export) {
    StringBuilder output = new StringBuilder();

    // Shadow window so that non-browser environments can pass their own global object here.
    output.append("(function(window){");

    // If $wnd is set to this, then JSInterop's normal export will run, and pollute the global
    // namespace. If export is false, fake out $wnd with an empty object.
    // (We also add Error to work around StackTraceCreator using it in a static block).
    output.append("var $wnd=").append(export ? "this" : "{'Error':{}}").append(";");

    // Shadow $doc, $moduleName and $moduleBase.
    output.append("var $doc={},$moduleName,$moduleBase;");

    // Append output JS.
    output.append(js);

    // 1. Export $gwtExport, needed for transpile.js
    // 2. Reset $wnd (nb. this occurs after jscompiler's JS has run)
    // 3. Call gwtOnLoad, if defined: this invokes onModuleLoad for all loaded modules.
    output.append("this['$gwtExport']=$wnd;$wnd=this;typeof gwtOnLoad==='function'&&gwtOnLoad()");

    // Overspecify the global object, to capture Node and browser environments.
    String globalObject = "this&&this.self||"
        + "(typeof window!=='undefined'?window:(typeof global!=='undefined'?global:this))";

    // Call the outer function with the global object as this and its first argument, so that we
    // fake window in Node environments, allowing our code to do things like "window.console(...)".
    output.append("}).call(").append(globalObject).append(",").append(globalObject).append(");");

    return output.toString();
  }
479548
public static void writeResults(final String name, final Object output) {
		Writer writer = null;

		try {
			writer = new BufferedWriter(
					new OutputStreamWriter(
					new FileOutputStream(name + ".json"), "utf-8"));

			writer.write(output.toString());
		} catch (IOException ignored) {
		} finally {
			try {writer.close();}
            catch (Exception ignored) {}
		}
	}