for use in removing unwanted boxed-content from appendices json
508880
def unwrap_appendix_box(json_content):
    """"""
    if json_content.get("content") and len(json_content["content"]) > 0:
        first_block = json_content["content"][0]
        if (first_block.get("type")
            and first_block.get("type") == "box"
            and first_block.get("content")):
            if first_block.get("doi") and not json_content.get("doi"):
                json_content["doi"] = first_block.get("doi")
            json_content["content"] = first_block["content"]
    return json_content
1020432
def remove_csv_from_json(d):
    
    logger_jsons.info("enter remove_csv_from_json")

    # Check both sections
    if "paleoData" in d:
        d = _remove_csv_from_section(d, "paleoData")

    if "chronData" in d:
        d = _remove_csv_from_section(d, "chronData")

    logger_jsons.info("exit remove_csv_from_json")
    return d
1055519
function escapeJsonQuotes(json) {
      return JSON.stringify(json)
        .replace(/'/g, "&amp;apos;")
        .replace(/"/g, "&amp;quot;")
        /**
         * Codepen was unescaping &lt; (<) and &gt; (>) which caused, on some demos,
         * an unclosed elements (like <md-select>).
         * Used different unicode lookalike characters so it won't be considered as an element
         */
        .replace(/&amp;lt;/g, "&#x02C2;") // http://graphemica.com/%CB%82
        .replace(/&amp;gt;/g, "&#x02C3;"); // http://graphemica.com/%CB%83
    }
133689
function() {
  var originalPackageJson;
  var cleanPackageJson = function() {
    return gulp.src([__dirname + '/package.json'])
    .pipe($.jsonEditor(function(){
      return originalPackageJson;
    }, {
      'end_with_newline': true
    }))
    .pipe(gulp.dest(__dirname + '/'));
  };

  /* Lazy dependencies installation */
  gulp.task('dirty-install-dep', function() {
    return gulp.src([__dirname + '/package.json'])
    .pipe($.jsonEditor(function(json) {
      var
        tplName = addons.templates[
          (config.modules && config.modules.templates) || 'handlebars'
        ].name,
        styleName = addons.styles[
          (config.modules && config.modules.styles) || 'less'
        ].name;
      originalPackageJson = JSON.parse(JSON.stringify(json));
      json.dependencies[tplName] = lazyDependencies[tplName];
      json.dependencies[styleName] = lazyDependencies[styleName];
      return json;
    }))
    .on('error', handleError)
    .pipe(gulp.dest(__dirname + '/'))
    .pipe($.install())
    .on('error', handleError);
  });
  gulp.task('install-dep', ['dirty-install-dep'], cleanPackageJson);

  /* Lazy dev dependencies installation */
  gulp.task('dirty-install-dev-dep', ['dirty-install-dep'], function() {
    return gulp.src([__dirname + '/package.json'])
    .pipe($.jsonEditor(function(json) {
      addons.dev.forEach(function(moduleName) {
        json.dependencies[moduleName] = lazyDependencies[moduleName];
      });
      return json;
    }))
    .on('error', handleError)
    .pipe(gulp.dest(__dirname + '/'))
    .pipe($.install())
    .on('error', handleError);
  });
  gulp.task('install-dev-dep', ['dirty-install-dev-dep'], cleanPackageJson);
}
140901
private String patchedJsonBody(WebSocketContext context) {
        String body = context.stringMessage();
        if (S.blank(body) || 1 < fieldsAndParamsCount) {
            return body;
        }
        String theName = singleJsonFieldName(context);
        int theNameLen = theName.length();
        if (null == theName) {
            return body;
        }
        body = body.trim();
        boolean needPatch = body.charAt(0) == '[';
        if (!needPatch) {
            if (body.charAt(0) != '{') {
                throw new IllegalArgumentException("Cannot parse JSON string: " + body);
            }
            boolean startCheckName = false;
            int nameStart = -1;
            for (int i = 1; i < body.length(); ++i) {
                char c = body.charAt(i);
                if (c == ' ') {
                    continue;
                }
                if (startCheckName) {
                    if (c == '"') {
                        break;
                    }
                    int id = i - nameStart - 1;
                    if (id >= theNameLen || theName.charAt(i - nameStart - 1) != c) {
                        needPatch = true;
                        break;
                    }
                } else if (c == '"') {
                    startCheckName = true;
                    nameStart = i;
                }
            }
        }
        return needPatch ? S.fmt("{\"%s\": %s}", theName, body) : body;
    }
181956
static function packageJson($project_directory, $app_engine_project, $app_engine_service, $package_json_defaults = []) {
        $package_json_location = $project_directory . DIRECTORY_SEPARATOR . "package.json";
        $package_json_content = Files::getJson($package_json_location, []);
        $package_json_content = array_merge([
            "name" => null,
            "project" => null,
            "private" => null,
        ], $package_json_content);
        $project_name = $app_engine_project . '-' . $app_engine_service;
        $package_json_defaults["private"] = true;
        $package_json_content["name"] = $project_name;
        $package_json_content["project"] = $app_engine_project;
        foreach ($package_json_defaults as $key => $val) {
            $package_json_content[$key] = $val;
        }
        if ($app_engine_service == "default") {
            $package_json_content["scripts"]["deploy"] = 'gcloud app deploy app.yaml queue.yaml --project $npm_package_project --promote --quiet';
        } else {
            $package_json_content["scripts"]["deploy"] = 'gcloud app deploy app.yaml --project $npm_package_project --promote --quiet';
        }
        $gaeutil_json = Files::getJson(Conf::getGaeUtilJsonPath($project_directory), []);

        $project_key_name = $gaeutil_json[Secrets::CONF_PROJECT_KEY_NAME];
        $project_key = Secrets::reverseKmsKey($project_key_name);
        $crypt_params = [
            "ciphertext-file" => "config/secrets.cipher",
            "plaintext-file" => "secrets.json",
            "project" => $project_key["project"],
            "location" => $project_key["location"],
            "keyring" => $project_key["keyRing"],
            "key" => $project_key["cryptoKey"]
        ];
        $package_json_content["scripts"]["encrypt"] = self::commandMaker("gcloud kms encrypt", $crypt_params);
        $package_json_content["scripts"]["decrypt"] = self::commandMaker("gcloud kms decrypt", $crypt_params);
        $package_json_content["scripts"]["devserve"] = 'dev_appserver.py --port=5000 . -A $npm_package_project';
        if (Files::putJson($package_json_location, $package_json_content)) {
            Util::cmdline("Updated package.json in $project_name");
        }

    }
398260
def iob2json(input_data, n_sents=10, *args, **kwargs):
    
    docs = []
    for group in minibatch(docs, n_sents):
        group = list(group)
        first = group.pop(0)
        to_extend = first["paragraphs"][0]["sentences"]
        for sent in group[1:]:
            to_extend.extend(sent["paragraphs"][0]["sentences"])
        docs.append(first)
    return docs
162989
def formatetfindexjson(fundbjson):
        """"""
        result = {}
        for row in fundbjson["rows"]:
            cell = row["cell"]
            fundb_id = cell["fund_id"]
            result[fundb_id] = cell
        return result
228313
def rewrite_elife_references_json(json_content, doi):
    
    references_rewrite_json = elife_references_rewrite_json()
    if doi in references_rewrite_json:
        json_content = rewrite_references_json(json_content, references_rewrite_json[doi])

    # Edge case delete one reference
    if doi == "10.7554/eLife.12125":
        for i, ref in enumerate(json_content):
            if ref.get("id") and ref.get("id") == "bib11":
                del json_content[i]

    return json_content
1249922
function parseConfigFileTextToJson(fileName, jsonText, stripComments) {
        if (stripComments === void 0) { stripComments = true; }
        try {
            var jsonTextToParse = stripComments ? removeComments(jsonText) : jsonText;
            return { config: /\S/.test(jsonTextToParse) ? JSON.parse(jsonTextToParse) : {} };
        }
        catch (e) {
            return { error: ts.createCompilerDiagnostic(ts.Diagnostics.Failed_to_parse_file_0_Colon_1, fileName, e.message) };
        }
    }
993288
def clean(docs=False, bytecode=False, extra=''):
    ''''''
    patterns = ['build', 'dist', 'cover', 'docs/_build', '**/*.pyc', '*.egg-info', '.tox', '**/__pycache__']
    for pattern in patterns:
        print('Removing {0}'.format(pattern))
        lrun('rm -rf {0}'.format(pattern))
881088
function(json, fields) {
    if (((typeof json) === 'object') && !Array.isArray(json))
      return hasFields(json,fields);
    else if (Array.isArray(json)) {
      var spliced = [];
      var n = json.length;
      while (n--)
        if (hasFields(json[n],fields))
          spliced.push(json[n]);

      if (spliced.length)
        return spliced;
      else
        return false;
    }
    else
      return console.error(new Error('Bad data passed to clean.forFields()'));
  }
1114033
def format_stack_frame_json(self):
        """"""
        stack_frame_json = {}
        stack_frame_json['function_name'] = get_truncatable_str(
            self.func_name)
        stack_frame_json['original_function_name'] = get_truncatable_str(
            self.original_func_name)
        stack_frame_json['file_name'] = get_truncatable_str(self.file_name)
        stack_frame_json['line_number'] = self.line_num
        stack_frame_json['column_number'] = self.col_num
        stack_frame_json['load_module'] = {
            'module': get_truncatable_str(self.load_module),
            'build_id': get_truncatable_str(self.build_id),
        }
        stack_frame_json['source_version'] = get_truncatable_str(
            self.source_version)

        return stack_frame_json
699899
function formatJson_(blockType, rootBlock) {
  var JS = {};
  // Type is not used by Blockly, but may be used by a loader.
  JS.type = blockType;
  // Generate inputs.
  var message = [];
  var args = [];
  var contentsBlock = rootBlock.getInputTargetBlock('INPUTS');
  var lastInput = null;
  while (contentsBlock) {
    if (!contentsBlock.disabled && !contentsBlock.getInheritedDisabled()) {
      var fields = getFieldsJson_(contentsBlock.getInputTargetBlock('FIELDS'));
      for (var i = 0; i < fields.length; i++) {
        if (typeof fields[i] == 'string') {
          message.push(fields[i].replace(/%/g, '%%'));
        } else {
          args.push(fields[i]);
          message.push('%' + args.length);
        }
      }

      var input = {type: contentsBlock.type};
      // Dummy inputs don't have names.  Other inputs do.
      if (contentsBlock.type != 'input_dummy') {
        input.name = contentsBlock.getFieldValue('INPUTNAME');
      }
      var check = JSON.parse(getOptTypesFrom(contentsBlock, 'TYPE') || 'null');
      if (check) {
        input.check = check;
      }
      var align = contentsBlock.getFieldValue('ALIGN');
      if (align != 'LEFT') {
        input.align = align;
      }
      args.push(input);
      message.push('%' + args.length);
      lastInput = contentsBlock;
    }
    contentsBlock = contentsBlock.nextConnection &&
        contentsBlock.nextConnection.targetBlock();
  }
  // Remove last input if dummy and not empty.
  if (lastInput && lastInput.type == 'input_dummy') {
    var fields = lastInput.getInputTargetBlock('FIELDS');
    if (fields && getFieldsJson_(fields).join('').trim() != '') {
      var align = lastInput.getFieldValue('ALIGN');
      if (align != 'LEFT') {
        JS.lastDummyAlign0 = align;
      }
      args.pop();
      message.pop();
    }
  }
  JS.message0 = message.join(' ');
  if (args.length) {
    JS.args0 = args;
  }
  // Generate inline/external switch.
  if (rootBlock.getFieldValue('INLINE') == 'EXT') {
    JS.inputsInline = false;
  } else if (rootBlock.getFieldValue('INLINE') == 'INT') {
    JS.inputsInline = true;
  }
  // Generate output, or next/previous connections.
  switch (rootBlock.getFieldValue('CONNECTIONS')) {
    case 'LEFT':
      JS.output =
          JSON.parse(getOptTypesFrom(rootBlock, 'OUTPUTTYPE') || 'null');
      break;
    case 'BOTH':
      JS.previousStatement =
          JSON.parse(getOptTypesFrom(rootBlock, 'TOPTYPE') || 'null');
      JS.nextStatement =
          JSON.parse(getOptTypesFrom(rootBlock, 'BOTTOMTYPE') || 'null');
      break;
    case 'TOP':
      JS.previousStatement =
          JSON.parse(getOptTypesFrom(rootBlock, 'TOPTYPE') || 'null');
      break;
    case 'BOTTOM':
      JS.nextStatement =
          JSON.parse(getOptTypesFrom(rootBlock, 'BOTTOMTYPE') || 'null');
      break;
  }
  // Generate colour.
  var colourBlock = rootBlock.getInputTargetBlock('COLOUR');
  if (colourBlock && !colourBlock.disabled) {
    var hue = parseInt(colourBlock.getFieldValue('HUE'), 10);
    JS.colour = hue;
  }
  JS.tooltip = '';
  JS.helpUrl = 'http://www.example.com/';
  return JSON.stringify(JS, null, '  ');
}
339199
function _copyPackageJson(from, to) {
  return new Promise((resolve, reject) => {
    const origin = path.join(from, 'package.json');
    const destination = path.join(to, 'package.json');
    let data = JSON.parse(fs.readFileSync(origin, 'utf-8'));
    delete data.engines;
    delete data.scripts;
    delete data.devDependencies;
    fs.writeFileSync(destination, JSON.stringify(data, null, 2));
    resolve();
  });
}
805719
function convertPropsToJson(text) {
    var configObject = {};
    if (text && text.length) {
        // handle multi-line values terminated with a backslash
        text = text.replace(/\\\r?\n\s*/g, '');
        text.split(/\r?\n/g).forEach(function (line) {
            var props,
                name,
                val;
            line = line.trim();
            if (line && line.indexOf("#") !== 0 && line.indexOf("!") !== 0) {
                props = line.split(/\=(.+)?/);
                name = props[0] && props[0].trim();
                val = props[1] && props[1].trim();
                configObject[name] = _convertStringIfTrue(val);
            }
        });
    }
    return configObject;
}
334146
function appendCode() {
    if (state === "code") {
      state = "text";
      if (!isWhitespace(codeBuffer)) {
        content += codeOpen + codeBuffer.replace(/^(?:\s*\n)+/, "").replace(/[\s\n]*$/, "") + codeClose;
      }
      codeBuffer = "";
    }
  }