Old `json` BIF.

@api private
548031
function oldJson(json, local, namePrefix){
  if (namePrefix) {
    utils.assertString(namePrefix, 'namePrefix');
    namePrefix = namePrefix.val;
  } else {
    namePrefix = '';
  }
  local = local ? local.toBoolean() : new nodes.Boolean(local);
  var scope = local.isTrue ? this.currentScope : this.global.scope;

  convert(json);
  return;

  function convert(obj, prefix){
    prefix = prefix ? prefix + '-' : '';
    for (var key in obj){
      var val = obj[key];
      var name = prefix + key;
      if ('object' == typeof val) {
        convert(val, name);
      } else {
        val = utils.coerce(val);
        if ('string' == val.nodeName) val = utils.parseString(val.string);
        scope.add({ name: namePrefix + name, val: val });
      }
    }
  }
}
175573
def json_data(self, instance, default=None):
        
        value = self.get(instance)
        return api.to_iso_date(value) or default
1251310
public function remakeJson()
    {
        $json = json_encode([
            'last_remote_check' => (!is_null($this->lastRemoteCheck) ? $this->lastRemoteCheck->timestamp : null),
            'hooks'             => $this->hooks(),
        ], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);

        file_put_contents(base_path('hooks/hooks.json'), $json);
    }
368581
def convert
      old = @hashes
      @hashes = Hash.new

      puts 'Warning: old JSON format detected, converting.'
      old.each {|i| add_hash(i[:id], i[:deletehash], 'unknown') }
      save
    end
724856
def serialize_old_format
      buf = [version].pack('V')
      buf << Bitcoin.pack_var_int(inputs.length) << inputs.map(&:to_payload).join
      buf << Bitcoin.pack_var_int(outputs.length) << outputs.map(&:to_payload).join
      buf << [lock_time].pack('V')
      buf
    end
1234919
def pretty_json(data):
    
    data = json.loads(data.decode('utf-8'))
    return json.dumps(data, indent=4, sort_keys=True)
8733
def dump_json(obj):
    """"""
    return simplejson.dumps(obj, ignore_nan=True, default=json_util.default)
328947
def as_json(options=nil)
      return {} if messages.empty?
      attribute, types = messages.first
      type             = types.first

      {
        :error => {
          :param => attribute,
          :type  => type,
          :message => nil
        }
      }
    end
57763
function toJSON() {
    var s = this;
    var values = Object.assign({}, s.schema);
    Object.keys(values).forEach(function (key) {
      var isFunc = iftype.isFunction(values[key]);

      if (isFunc) {
        delete values[key];
      }
    });
    return values;
  }
820049
def build_json(self, guid):
        """"""
        upserts = []
        for value in self.upserts:
            upserts.append({"value": value, "criteria": self.upserts[value]})
        return json.dumps({'replace_all': self.replace_all, 'guid': guid,
                           'complete': self.complete, 'upserts': upserts, 'deletes': self.deletes})
1361122
function toJSON() {
    function filter(obj) {
      return Object.keys(obj)
        .filter(function(key) {
          return typeof obj[key] !== 'function' && key[0] !== '_';
        })
        .reduce(function(clone, key) {
          clone[key] = typeof obj[key] !== 'object' ?
            obj[key] : filter(obj[key]);
          return clone;
        }, Array.isArray(obj) ? [] : {});
    }
    return JSON.stringify(filter(obj));
  }
971859
function () {
    this.objectPool.recycle(this.attrValue);
    this.objectPool.recycle(this.oldData);
    this.objectPool.recycle(this.parsingAttrValue);
    this.attrValue = this.oldData = this.parsingAttrValue = undefined;
  }
7442
def __obj2json(self, obj):
        
        return json.dumps(obj, indent=self._indent, sort_keys=self._sort_keys)
554994
def lastProgress(self):
        
        lastProgress = self._jsq.lastProgress()
        if lastProgress:
            return json.loads(lastProgress.json())
        else:
            return None
648615
function( version ) {

    version = version || '4.0'

    var keys = Object.keys( this.data )
    var data = [ [ 'version', {}, 'text', version ] ]
    var prop = null

    for( var i = 0; i < keys.length; i++ ) {
      if( keys[i] === 'version' ) continue;
      prop = this.data[ keys[i] ]
      if( Array.isArray( prop ) ) {
        for( var k = 0; k < prop.length; k++ ) {
          data.push( prop[k].toJSON() )
        }
      } else {
        data.push( prop.toJSON() )
      }
    }

    return [ 'vcard', data ]

  }
392258
def update(self, **kwargs):
        

        old_json = self.__json__()

        for prop in kwargs:
            setattr(self, prop, kwargs[prop])

        # We send notif only if object has changed
        if old_json != self.__json__():
            self.controller.notification.emit("project.updated", self.__json__())
            self.dump()
1348437
def elife_references_rewrite_json():
    
    references_rewrite_json = {}

    references_rewrite_json["10.7554/eLife.00051"] = {"bib25": {"date": "2012"}}
    references_rewrite_json["10.7554/eLife.00278"] = {"bib11": {"date": "2013"}}
    references_rewrite_json["10.7554/eLife.00444"] = {"bib2": {"date": "2013"}}
    references_rewrite_json["10.7554/eLife.00569"] = {"bib74": {"date": "1996"}}
    references_rewrite_json["10.7554/eLife.00592"] = {"bib8": {"date": "2013"}}
    references_rewrite_json["10.7554/eLife.00633"] = {"bib38": {"date": "2004"}}
    references_rewrite_json["10.7554/eLife.00646"] = {"bib1": {"date": "2012"}}
    references_rewrite_json["10.7554/eLife.00813"] = {"bib33": {"date": "2007"}}
    references_rewrite_json["10.7554/eLife.01355"] = {"bib9": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.01530"] = {"bib12": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.01681"] = {"bib5": {"date": "2000"}}
    references_rewrite_json["10.7554/eLife.01917"] = {"bib35": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.02030"] = {"bib53": {"date": "2013"}, "bib56": {"date": "2013"}}
    references_rewrite_json["10.7554/eLife.02076"] = {"bib93a": {"date": "1990"}}
    references_rewrite_json["10.7554/eLife.02217"] = {"bib27": {"date": "2009"}}
    references_rewrite_json["10.7554/eLife.02535"] = {"bib12": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.02862"] = {"bib8": {"date": "2010"}}
    references_rewrite_json["10.7554/eLife.03711"] = {"bib35": {"date": "2012"}}
    references_rewrite_json["10.7554/eLife.03819"] = {"bib37": {"date": "2008"}}
    references_rewrite_json["10.7554/eLife.04069"] = {"bib8": {"date": "2011"}}
    references_rewrite_json["10.7554/eLife.04247"] = {"bib19a": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.04333"] = {
        "bib3": {"date": "1859"},
        "bib37": {"date": "1959"}}
    references_rewrite_json["10.7554/eLife.04478"] = {"bib49": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.04580"] = {"bib139": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.05042"] = {"bib78": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.05323"] = {"bib102": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.05423"] = {"bib102": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.05503"] = {"bib94": {"date": "2016"}}
    references_rewrite_json["10.7554/eLife.05849"] = {"bib82": {"date": "2005"}}
    references_rewrite_json["10.7554/eLife.06072"] = {"bib17": {"date": "2003"}}
    references_rewrite_json["10.7554/eLife.06315"] = {"bib19": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.06426"] = {"bib39": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.07361"] = {"bib76": {"date": "2011"}}
    references_rewrite_json["10.7554/eLife.07460"] = {
        "bib1": {"date": "2013"},
        "bib2": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.08500"] = {"bib55": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.09066"] = {"bib46": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.09100"] = {"bib50": {"date": "2011"}}
    references_rewrite_json["10.7554/eLife.09148"] = {
        "bib47": {"articleTitle": "97–104"},
        "bib59": {"articleTitle": "1913–1918"}}
    references_rewrite_json["10.7554/eLife.09186"] = {
        "bib31": {"date": "2015"},
        "bib54": {"date": "2014"},
        "bib56": {"date": "2014"},
        "bib65": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.09215"] = {"bib5": {"date": "2012"}}

    references_rewrite_json["10.7554/eLife.09520"] = {
        "bib35": OrderedDict([
            ("conference", OrderedDict([
                ("name", ["WHO Expert Committee on Malaria"])
            ])),
            ("articleTitle", "WHO Expert Committee on Malaria [meeting held in Geneva from 19 to 30 October 1970]: fifteenth report"),
            ("publisher", OrderedDict([
                ("name", ["World Health Organization"]),
                ("address", OrderedDict([
                    ("formatted", ["Geneva"]),
                    ("components", OrderedDict([
                        ("locality", ["Geneva"])
                    ])),
                ])),
            ])),
        ])
    }

    references_rewrite_json["10.7554/eLife.09579"] = {
        "bib19": {"date": "2007"},
        "bib49": {"date": "2002"}}
    references_rewrite_json["10.7554/eLife.09600"] = {"bib13": {"date": "2009"}}
    references_rewrite_json["10.7554/eLife.09672"] = {
        "bib25": {"conference": {"name": ["Seventeenth Meeting of the RBM Partnership Monitoring and Evaluation Reference Group (MERG)"]}}}
    references_rewrite_json["10.7554/eLife.09771"] = {"bib22": {"date": "2012"}}
    references_rewrite_json["10.7554/eLife.09972"] = {"bib61": {"date": "2007", "discriminator": "a"}}
    references_rewrite_json["10.7554/eLife.09977"] = {"bib41": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.10032"] = {"bib45": {"date": "2016"}}
    references_rewrite_json["10.7554/eLife.10042"] = {"bib14": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.10070"] = {"bib15": {"date": "2015"}, "bib38": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.10222"] = {"bib30": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.10670"] = {"bib7": {"date": "2015"}, "bib8": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.10781"] = {"bib32": {"date": "2003"}}
    references_rewrite_json["10.7554/eLife.11273"] = {"bib43": {"date": "2004"}}
    references_rewrite_json["10.7554/eLife.11305"] = {"bib68": {"date": "2000"}}
    references_rewrite_json["10.7554/eLife.11416"] = {"bib22": {"date": "1997"}}
    references_rewrite_json["10.7554/eLife.11860"] = {"bib48": {"title": "Light-switchable gene expression system"}}
    references_rewrite_json["10.7554/eLife.12401"] = {"bib25": {"date": "2011"}}
    references_rewrite_json["10.7554/eLife.12366"] = {"bib10": {"date": "2008"}}
    references_rewrite_json["10.7554/eLife.12703"] = {"bib27": {"date": "2013"}}
    references_rewrite_json["10.7554/eLife.12735"] = {"bib35": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.12830"] = {"bib118": {"date": "1982"}}
    references_rewrite_json["10.7554/eLife.13133"] = {"bib11": {"date": "2011"}}
    references_rewrite_json["10.7554/eLife.13152"] = {"bib25": {"date": "2000"}}
    references_rewrite_json["10.7554/eLife.13195"] = {"bib6": {"date": "2013"}, "bib12": {"date": "2003"}}
    references_rewrite_json["10.7554/eLife.13479"] = {"bib5": {"date": "2016"}}
    references_rewrite_json["10.7554/eLife.13463"] = {"bib15": {"date": "2016"}}
    references_rewrite_json["10.7554/eLife.14119"] = {"bib40": {"date": "2007"}}
    references_rewrite_json["10.7554/eLife.14169"] = {"bib6": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.14523"] = {"bib7": {"date": "2013"}}
    references_rewrite_json["10.7554/eLife.15272"] = {"bib78": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.15504"] = {"bib67": {"isbn": "9780198524304"}}
    references_rewrite_json["10.7554/eLife.16105"] = {"bib2": {"date": "2013"}}
    references_rewrite_json["10.7554/eLife.16349"] = {"bib68": {"date": "2005"}}
    references_rewrite_json["10.7554/eLife.16394"] = {
        "bib6": {"type": "thesis",
        "author": {"type": "person", "name": {"preferred": "B Berret","index": "Berret, B" }},
        "publisher": {"name": ["Université de Bourgogne"]}}}
    references_rewrite_json["10.7554/eLife.16443"] = {"bib58": {"date": "1987"}}
    references_rewrite_json["10.7554/eLife.16764"] = {"bib4": {"date": "2013"}}
    references_rewrite_json["10.7554/eLife.17092"] = {"bib102": {"date": "1980"}}
    references_rewrite_json["10.7554/eLife.18044"] = {"bib25": {"date": "2005"}}
    references_rewrite_json["10.7554/eLife.18370"] = {"bib1": {"date": "2006"}}
    references_rewrite_json["10.7554/eLife.18425"] = {"bib54": {"date": "2014"}}
    references_rewrite_json["10.7554/eLife.18683"] = {"bib47": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.19532"] = {"bib27": {"date": "2015"}}
    references_rewrite_json["10.7554/eLife.19545"] = {"bib51": {"date": "1996"}}
    references_rewrite_json["10.7554/eLife.19571"] = {"bib56": {"date": "2016"}}
    references_rewrite_json["10.7554/eLife.20352"] = {"bib53": {"country": "United States"}}
    references_rewrite_json["10.7554/eLife.21864"] = {"bib2": {"date": "2016-10-24"}}
    references_rewrite_json["10.7554/eLife.20522"] = {
        "bib42": {"date": "2016"},
        "bib110": {"date": "1996"}}
    references_rewrite_json["10.7554/eLife.22053"] = {"bib123": {"date": "2016"}}

    # Reference authors data to replace, processed further below into json
    references_authors = []
    references_authors.append(("10.7554/eLife.00036", "bib8", "authors", [
        {"surname": "Butler", "given-names": "H"},
        {"surname": "Juurlink", "given-names": "BHJ"}
        ]))
    references_authors.append(("10.7554/eLife.00036", "bib30", "authors", [
        {"surname": "Joyner", "given-names": "AL"}
        ]))

    references_authors.append(("10.7554/eLife.00048", "bib15", "authors", [
        {"surname": "Guthrie", "given-names": "C"},
        {"surname": "Fink", "given-names": "GR"}
        ]))

    references_authors.append(("10.7554/eLife.00051", "bib21", "authors", [
        {"surname": "Jamison", "given-names": "DT"},
        {"surname": "Breman", "given-names": "JG"},
        {"surname": "Measham", "given-names": "AR"},
        {"surname": "Alleyne", "given-names": "G"},
        {"surname": "Claeson", "given-names": "M"},
        {"surname": "Evans", "given-names": "DB"},
        {"surname": "Jha", "given-names": "P"},
        {"surname": "Mills", "given-names": "A"},
        {"surname": "Musgrove", "given-names": "P"}
        ]))
    references_authors.append(("10.7554/eLife.00051", "bib36", "authors", [
        {"surname": "Rogers", "given-names": "RG"},
        {"surname": "Crimmins", "given-names": "EM"}
        ]))

    references_authors.append(("10.7554/eLife.00668", "bib39", "authors", [
        {"surname": "Rice", "given-names": "SA"}
        ]))

    references_authors.append(("10.7554/eLife.01730", "bib75", "authors", [
        {"collab": "Look AHEAD Research Group"}
        ]))

    references_authors.append(("10.7554/eLife.03714", "bib64", "authors", [
        {"surname": "Otwinowski", "given-names": "Z"},
        {"surname": "Minor", "given-names": "W"}
        ]))

    references_authors.append(("10.7554/eLife.04220", "bib31", "authors", [
        {"surname": "Tishby", "given-names": "N"},
        {"surname": "Polani", "given-names": "D"}
        ]))

    references_authors.append(("10.7554/eLife.04395", "bib67", "authors", [
        {"surname": "King", "given-names": "AMQ"},
        {"surname": "Adams", "given-names": "MJ"},
        {"surname": "Carstens", "given-names": "EB"},
        {"surname": "Lefkowitz", "given-names": "E"}
        ]))

    references_authors.append(("10.7554/eLife.04449", "bib62", "authors", [
        {"surname": "Shaham", "given-names": "S"}
        ]))

    references_authors.append(("10.7554/eLife.04659", "bib57", "authors", [
        {"surname": "Sambrook", "given-names": "J"},
        {"surname": "Russell", "given-names": "TW"}
        ]))

    references_authors.append(("10.7554/eLife.05423", "bib4", "authors", [
        {"surname": "Birkhead", "given-names": "TR"},
        {"surname": "Møller", "given-names": "AP"}
        ]))
    references_authors.append(("10.7554/eLife.05423", "bib5", "authors", [
        {"surname": "Birkhead", "given-names": "TR"},
        {"surname": "Møller", "given-names": "AP"}
        ]))
    references_authors.append(("10.7554/eLife.05423", "bib90", "authors", [
        {"surname": "Smith", "given-names": "RL"}
        ]))

    references_authors.append(("10.7554/eLife.05564", "bib39", "authors", [
        {"surname": "Pattyn", "given-names": "S"}
        ]))

    references_authors.append(("10.7554/eLife.05959", "bib76", "authors", [
        {"surname": "Macholán", "given-names": "M"},
        {"surname": "Baird", "given-names": "SJE"},
        {"surname": "Munclinger", "given-names": "P"},
        {"surname": "Piálek", "given-names": "J"}
        ]))

    references_authors.append(("10.7554/eLife.06565", "bib1", "authors", [
        {"surname": "Ahringer", "given-names": "J"}
        ]))

    references_authors.append(("10.7554/eLife.06576", "bib57", "authors", [
        {"surname": "Moller", "given-names": "AR"}
        ]))

    references_authors.append(("10.7554/eLife.06813", "bib54", "authors", [
        {"surname": "King", "given-names": "JA"}
        ]))

    references_authors.append(("10.7554/eLife.06813", "bib55", "authors", [
        {"surname": "Kirkland", "given-names": "Gl"},
        {"surname": "Layne", "given-names": "JN"}
        ]))

    references_authors.append(("10.7554/eLife.07460", "bib1", "authors", [
        {"surname": "Rallapalli", "given-names": "Ghanasyam"}
        ]))
    references_authors.append(("10.7554/eLife.07460", "bib2", "authors", [
        {"surname": "Bazyl", "given-names": "Steven"}
        ]))

    references_authors.append(("10.7554/eLife.07847", "bib40", "authors", [
        {"collab": "Nature Immunology"}
        ]))

    references_authors.append(("10.7554/eLife.09666", "bib9", "authors", [
        {"surname": "Schüler", "given-names": "D"}
        ]))

    references_authors.append(("10.7554/eLife.09868", "bib5", "authors", [
        {"surname": "Barlow", "given-names": "HB"}
        ]))

    references_authors.append(("10.7554/eLife.10222", "bib30", "authors", [
        {"collab": "PharmaMar"}
        ]))

    references_authors.append(("10.7554/eLife.11860", "bib48", "authors", [
        {"surname": "Yang", "given-names": "Y"},
        {"surname": "Wang", "given-names": "X"},
        {"surname": "Chen", "given-names": "X"},
        ]))

    references_authors.append(("10.7554/eLife.11945", "bib23", "authors", [
        {"surname": "Glimcher", "given-names": "P"},
        {"surname": "Fehr", "given-names": "E"}
        ]))

    references_authors.append(("10.7554/eLife.13135", "bib26", "authors", [
        {"surname": "Ivanova", "given-names": "S"},
        {"surname": "Herbreteau", "given-names": "B"},
        {"surname": "Blasdell", "given-names": "K"},
        {"surname": "Chaval", "given-names": "Y"},
        {"surname": "Buchy", "given-names": "P"},
        {"surname": "Guillard", "given-names": "B"},
        {"surname": "Morand", "given-names": "S"},
        ]))

    references_authors.append(("10.7554/eLife.13135", "bib27", "authors", [
        {"surname": "King", "given-names": "AMQ"},
        {"surname": "Adams", "given-names": "J"},
        {"surname": "Carstens", "given-names": "EB"},
        {"surname": "Lefkowitz", "given-names": "EJ"}
        ]))

    references_authors.append(("10.7554/eLife.14188", "bib1", "authors", [
        {"collab": "Avisoft Bioacoustics"}
        ]))

    references_authors.append(("10.7554/eLife.17716", "bib7", "authors", [
        {"collab": "World Health Organization"}
        ]))

    references_authors.append(("10.7554/eLife.17956", "bib4", "authors", [
        {"surname": "Barrett", "given-names": "SCH"}
        ]))

    references_authors.append(("10.7554/eLife.18109", "bib39", "authors", [
        {"surname": "Weber", "given-names": "EH"}
        ]))


    # Now turn the authors data into the json
    for author_row in references_authors:
        ref_json = OrderedDict()
        doi, id, author_type, authors = author_row
        #if id not in ref_json:
        ref_json[id] = OrderedDict()
        ref_json[id][author_type] = []
        for ref_author in authors:
            if  "collab" in ref_author:
                author_json = elifetools.utils_html.references_author_collab(ref_author)
            else:
                author_json = elifetools.utils.references_author_person(ref_author)
            if author_json:
                ref_json[id][author_type].append(author_json)
        # Add to json array, and do not verwrite existing rule of a specific bib id (if present)
        if doi not in references_rewrite_json:
            references_rewrite_json[doi] = ref_json
        else:
            for key, value in iteritems(ref_json):
                if key not in references_rewrite_json[doi]:
                    references_rewrite_json[doi][key] = value
                else:
                    # Append dict items
                    for k, v in iteritems(value):
                        references_rewrite_json[doi][key][k] = v

    return references_rewrite_json