Lawnchair!
---
clientside json store
767611
function (options, callback) {
    // ensure Lawnchair was called as a constructor
    if (!(this instanceof Lawnchair)) return new Lawnchair(options, callback);

    // lawnchair requires json 
    if (!JSON) throw 'JSON unavailable! Include http://www.json.org/json2.js to fix.'
    // options are optional; callback is not
    if (arguments.length <= 2) {
        callback = (typeof arguments[0] === 'function') ? arguments[0] : arguments[1];
        options  = (typeof arguments[0] === 'function') ? {} : arguments[0] || {};
    } else {
        throw 'Incorrect # of ctor args!'
    }
    
    // default configuration 
    this.record = options.record || 'record'  // default for records
    this.name   = options.name   || 'records' // default name for underlying store
    
    // mixin first valid  adapter
    var adapter
    // if the adapter is passed in we try to load that only
    if (options.adapter) {
        
        // the argument passed should be an array of prefered adapters
        // if it is not, we convert it
        if(typeof(options.adapter) === 'string'){
            options.adapter = [options.adapter];    
        }
            
        // iterates over the array of passed adapters 
        for(var j = 0, k = options.adapter.length; j < k; j++){
            
            // itirates over the array of available adapters
            for (var i = Lawnchair.adapters.length-1; i >= 0; i--) {
                if (Lawnchair.adapters[i].adapter === options.adapter[j]) {
                    adapter = Lawnchair.adapters[i].valid() ? Lawnchair.adapters[i] : undefined;
                    if (adapter) break 
                }
            }
            if (adapter) break
        }
    
    // otherwise find the first valid adapter for this env
    } 
    else {
        for (var i = 0, l = Lawnchair.adapters.length; i < l; i++) {
            adapter = Lawnchair.adapters[i].valid() ? Lawnchair.adapters[i] : undefined
            if (adapter) break 
        }
    } 
    
    // we have failed 
    if (!adapter) throw 'No valid adapter.' 
    
    // yay! mixin the adapter 
    for (var j in adapter)  
        this[j] = adapter[j]
    
    // call init for each mixed in plugin
    for (var i = 0, l = Lawnchair.plugins.length; i < l; i++) 
        Lawnchair.plugins[i].call(this)

    // init the adapter 
    this.init(options, callback)
}
320640
function JSON_ () {
  var self = this

  self.klass = JSON_;
  self.klass.super_.apply(self, arguments);

  self.engine = JSON;
  self.binary = false;
}
223000
def _dirjson (x)
    x = Pathname.new(x)
    x.entries.find_all {|f| f.to_s =~ /\.json$/i}.
      map {|f| x + f}
  end
512765
def publish_json(self, channel, obj):
        """"""
        return self.publish(channel, json.dumps(obj))
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");
        }

    }
1314080
function (store, json) {
    var i, args = slice.call(arguments, 2), len = args.length, records, typeKey;
    for (i = 0; i < len; i += 2) {
      records = args[i + 1];
      records = records ? (isArray(records) ? records.slice() : [records]) : [];
      typeKey = pluralize(this._parseModelOrType(store, args[i]).typeKey);
      if (!json[typeKey]) {
        json[typeKey] = records;
      }
      else {
        injectNoConflict(json[typeKey], records);
      }
    }
    return json;
  }
598618
def jsonld(client, records):
    
    from renku.models._json import dumps
    from renku.models._jsonld import asjsonld

    data = [asjsonld(record) for record in records]
    echo_via_pager(dumps(data, indent=2))
1125009
function buildJsonSchema(comments) {

    // skeleton schema object
    var schema = {
        properties: {
        }
    };

    // go through each comment block
    (comments || []).forEach(function(block) {

        // we're only interested in customTags (none standard jsDoc comments i.e. @schema.)
        (block.customTags || []).forEach(function(item) {

            var tag = item.tag.replace('schema.', '');
            var value = item.value || '';

            // skip properties with no value
            if (value === '') return;

            if (block.scope === 'global') {
                schema[tag] = value;
            }
            else {

                // item is a property
                schema.properties[block.name] = schema.properties[block.name] || {};

                // jsdoc-parse lowercase tag names, so we need more case blocks to correct this
                switch (tag) {

                    /* integers */

                    case 'minimum':
                    case 'maximum': {
                        schema.properties[block.name][tag] = parseInt(value, 10);
                    } break;

                    case 'minitems': {
                        schema.properties[block.name].minItems = parseInt(value, 10);
                    } break;

                    case 'maxitems': {
                        schema.properties[block.name].maxItems = parseInt(value, 10);
                    } break;

                    case 'minlength': {
                        schema.properties[block.name].minLength = parseInt(value, 10);
                    } break;

                    case 'maxlength': {
                        schema.properties[block.name].maxLength = parseInt(value, 10);
                    } break;

                    case 'exclusiveminimum': {
                        schema.properties[block.name].exclusiveMinimum = parseInt(value, 10);
                    } break;

                    case 'exclusivemaximum': {
                        schema.properties[block.name].exclusiveMaximum = parseInt(value, 10);
                    } break;

                    case 'divisibleby': {
                        schema.properties[block.name].divisibleBy = parseInt(value, 10);
                    } break;

                    /* boolean's */

                    case 'required': {
                        schema.properties[block.name][tag] = (value === 'true');
                    } break;

                    case 'uniqueitems': {
                        schema.properties[block.name].uniqueItems = (value === 'true');
                    } break;

                    /* strings */

                    case 'extends':
                    case 'id':
                    case 'type':
                    case 'pattern':
                    case 'title':
                    case 'format':
                    case 'disallow':
                    case 'extends':
                    case 'enum':
                    case 'description':
                    case 'name':
                    case 'default':
                    default: {
                        schema.properties[block.name][tag] = value;
                    } break;
                }
            }

        });
    });

    return schema;
}
1329810
@Nullable
    private static Object json(@Nullable Object in) {
        if (in == null) return null;
        return new Object() {
            @Override
            public String toString() {
                return "{\"fake-key\": \"fake-value\"}";
            }
        };
    }
1044741
def as_json(options = {})
      {name: self.name, title: self.title}.merge(options).tap do |options|
        fields.each {|f| options.merge!({f.code_name.to_sym => f.get_value_for(self)})}
      end
    end
65582
def json(self):
        '''  '''
        if 'application/json' in self.environ.get('CONTENT_TYPE', '') \
        and 0 < self.content_length < self.MEMFILE_MAX:
            return json_loads(self.body.read(self.MEMFILE_MAX))
        return None
1318840
def _create_json(self):
        
        data_json = super(GroupLDAP, self)._create_json()
        data_json.update({
            'realmAttributes': self.realmAttributes,
            'external': True,
        })
        return data_json
438218
def json(self, command, arguments, tags=None, id=None):
        
        result = self.sync(command, arguments, tags=tags, id=id)
        if result.level != 20:
            raise RuntimeError('invalid result level, expecting json(20) got (%d)' % result.level)

        return json.loads(result.data)
187115
private static JsonArray getJsonArray(List<String> keys) {
        JsonArray array = new JsonArray();
        for (String key : keys) {
            array.add(key);
        }

        return array;
    }
41122
function() {
		if (fs.existsSync(catalogFile)) {
			var content = fs.readFileSync(catalogFile);
			return JSON.parse(content);
		}

		return {};
	}
1321086
def field_pklist_from_json(self, data):
        
        model = get_model(data['app'], data['model'])
        return PkOnlyQueryset(self, model, data['pks'])
1188566
function asJson(entity, shallow) {
  let json;

  try {
    json = JSON.stringify(asObject(entity, shallow));
  } catch (error) {
    json = '';
  }

  return json;
}