Creates an options json that stores the options for a generic rule.
498124
function(options) {
    return {
      element: options.element,
      name:    'Do not use ' + options.element + ' element',
      message: 'Please remove the ' + options.element + ' element',
      ruleUrl:  options.ruleUrl,
      level:    options.level,
      template: true,
      callback: createGenericCallback(options.element)
    };
  }
416915
def _create_json(self):
        
        data_json = {
            "name": self.name,
            "includesPattern": self.includesPattern,
            "excludesPattern": self.excludesPattern,
            "repositories": self._repositories,
            "principals": {
                'users': self._users,
                'groups': self._groups,
            }
        }
        return data_json
1143639
public static <T extends Option> T fromJSON(String json, Class<T> type) {
        Gson gson = new GsonBuilder().setPrettyPrinting().
                registerTypeAdapter(Series.class, new SeriesDeserializer()).
                registerTypeAdapter(Axis.class, new AxisDeserializer()).create();
        return gson.fromJson(json, type);
    }
269836
def to_json(cls, config, compact=False, indent=2, level=0):
        
        lines = ""
        if isinstance(config, ConfigTree):
            if len(config) == 0:
                lines += '{}'
            else:
                lines += '{\n'
                bet_lines = []
                for key, item in config.items():
                    bet_lines.append('{indent}"{key}": {value}'.format(
                        indent=''.rjust((level + 1) * indent, ' '),
                        key=key.strip('"'),  # for dotted keys enclosed with "" to not be interpreted as nested key
                        value=cls.to_json(item, compact, indent, level + 1))
                    )
                lines += ',\n'.join(bet_lines)
                lines += '\n{indent}}}'.format(indent=''.rjust(level * indent, ' '))
        elif isinstance(config, list):
            if len(config) == 0:
                lines += '[]'
            else:
                lines += '[\n'
                bet_lines = []
                for item in config:
                    bet_lines.append('{indent}{value}'.format(
                        indent=''.rjust((level + 1) * indent, ' '),
                        value=cls.to_json(item, compact, indent, level + 1))
                    )
                lines += ',\n'.join(bet_lines)
                lines += '\n{indent}]'.format(indent=''.rjust(level * indent, ' '))
        elif isinstance(config, basestring):
            lines = json.dumps(config)
        elif config is None or isinstance(config, NoneValue):
            lines = 'null'
        elif config is True:
            lines = 'true'
        elif config is False:
            lines = 'false'
        else:
            lines = str(config)
        return lines
1350921
function toJSON(value, options) {
  var propertyOrValues = {}
  var lines
  var isPropertyValuePair
  var pairs
  var values

  if (!options) {
    options = {}
  }

  if (options.log === null || options.log === undefined) {
    options.log = true
  }

  if (options.comment === null || options.comment === undefined) {
    options.comment = '%'
  }

  lines = value.split('\n')

  if (options.comment) {
    lines = lines.map(stripComments(options.comment))
  }

  lines = lines.map(trim).filter(Boolean)

  pairs = lines.map(toPropertyValuePairs(options.delimiter || ':'))

  pairs.forEach(function(line, index) {
    var currentLineIsPropertyValuePair

    currentLineIsPropertyValuePair = line.length === 2

    if (index === 0) {
      isPropertyValuePair = currentLineIsPropertyValuePair
    } else if (currentLineIsPropertyValuePair !== isPropertyValuePair) {
      throw new Error(
        'Error at `' +
          line +
          '`: ' +
          'Both property-value pairs and array values found. ' +
          'Make sure either exists.'
      )
    }

    if (own.call(propertyOrValues, line[0])) {
      if (
        !options.forgiving ||
        (options.forgiving === true &&
          currentLineIsPropertyValuePair &&
          line[1] !== propertyOrValues[line[0]])
      ) {
        throw new Error(
          'Error at `' +
            line +
            '`: ' +
            'Duplicate data found. ' +
            'Make sure, in objects, no duplicate properties exist;' +
            'in arrays, no duplicate values.'
        )
      }

      if (options.log) {
        if (
          options.forgiving === 'fix' &&
          propertyOrValues[line[0]] !== line[1]
        ) {
          console.log(
            'Overwriting `' +
              propertyOrValues[line[0]] +
              '` ' +
              'to `' +
              line[1] +
              '` for `' +
              line[0] +
              '`'
          )
        } else {
          console.log('Ignoring duplicate key for `' + line[0] + '`')
        }
      }
    }

    propertyOrValues[line[0]] = line[1]
  })

  if (isPropertyValuePair) {
    pairs.sort(sortOnFirstIndex)
    values = propertyValuePairsToObject(pairs)
  } else {
    lines.sort()
  }

  return values || lines
}
355066
function makeOptionsSchema(additionalProperties) {
  const base =  {
    'type': 'object',
    'properties': {
      'commonjs': { 'type': 'boolean' },
      'amd': { 'type': 'boolean' },
      'esmodule': { 'type': 'boolean' },
      'ignore': {
        'type': 'array',
        'minItems': 1,
        'items': { 'type': 'string' },
        'uniqueItems': true,
      },
    },
    'additionalProperties': false,
  }

  if (additionalProperties){
    for (let key in additionalProperties) {
      base.properties[key] = additionalProperties[key]
    }
  }

  return base
}
621655
def as_json(options={})
      options = @options.merge(options)

      if options[:root]
        { options[:root].to_sym => serializable_hash }.merge(meta_hash).merge(data_hash)
      else
        serializable_hash
      end
    end
86499
public static Option fromJSON(String json) {
        Gson gson = new GsonBuilder().setPrettyPrinting().
                registerTypeAdapter(Series.class, new SeriesDeserializer()).
                registerTypeAdapter(Axis.class, new AxisDeserializer()).create();
        Option option = gson.fromJson(json, Option.class);
        return option;
    }
242334
function(options) {
      var t = this,
          opts = _.extend({trim:true, deep:true}, options),
          raw = Backbone.Model.prototype.toJSON.call(t, opts);
      return raw;
    }
1016782
public static PactDslJsonRootValue or(Object example, MatchingRule... rules) {
    PactDslJsonRootValue value = new PactDslJsonRootValue();
    if (example != null) {
      value.setValue(example);
    } else {
      value.setValue(JSONObject.NULL);
    }
    value.matchers.setRules("", new MatchingRuleGroup(Arrays.asList(rules), RuleLogic.OR));
    return value;
  }
1339644
def as_json(options = {})
      result = self.attributes
      result['organization'] = self.organization.try(:name)
      result['environments'] = environments.map { |e| e.try(:name) }
      result['versions'] = versions.map(&:version)
      result['versions_details'] = versions.map do |v|
        {
          :version => v.version,
          :published => v.created_at.to_s,
          :environments => v.environments.map { |e| e.name }
        }
      end

      if options && options[:environment].present?
        result['repositories'] = repos(options[:environment]).map(&:name)
      end

      result
    end
1032653
function(pluginOptions) {
    if (!pluginOptions) {
        pluginOptions = {
            comments: false
        };
    }

    // Default options
    if (typeof pluginOptions.comments !== 'boolean') {
        pluginOptions.comments = false;
    }

    return map(function(file, cb) {
        var result = jsonlint(file.contents.toString('utf8'), pluginOptions);
        file.jsonlint = {
            error: result.error,
            line: result.line,
            character: result.character
        };

        // Pass file
        cb(null, file);
    });
}
1075443
async function storeOptions(options){
    await _fs.writeFile(_configFilename, JSON.stringify(options, null, 4));
}
626018
def to_json(options = nil)
      mapper = (options.nil? || !options.key?(:mapper))? self.class.mapper: options[:mapper]
      object = (options.nil? || !options.key?(:object))? self: options[:object]
      serialize(mapper, object)
    end
1012149
private static JsonStructure toJson( ITestCaseGenerator generator)
    {
    JsonObjectBuilder builder = Json.createObjectBuilder();

    if( generator.getClass().equals( TupleGenerator.class))
      {
      TupleGenerator tupleGenerator = (TupleGenerator) generator;
      builder.add( TUPLES_KEY, tupleGenerator.getDefaultTupleSize());
      Optional.ofNullable( tupleGenerator.getRandomSeed()).ifPresent( seed -> builder.add( SEED_KEY, seed));
      
      JsonArrayBuilder combinersBuilder = Json.createArrayBuilder();
      tupleGenerator.getCombiners().stream().forEach( combiner -> combinersBuilder.add( toJson( combiner)));
      JsonArray combiners = combinersBuilder.build();
      if( !combiners.isEmpty())
        {
        builder.add( COMBINERS_KEY, combiners);
        }
      }

    return builder.build();
    }
1311074
def as_json(options = {})
      {}.tap do |result|
        result[:body] = @body unless @body.nil?
        result[:headers] = @headers unless @headers.nil?
        result[:status] = @status unless @status.nil?
      end
    end
311496
def as_json(_options = {})
      hash = {}
      instance_variables.each do |var|
        name = var[1..-1]

        if name =~ /^__/
          # if a variable starts with double underscore, strip one off
          name = name[1..-1]
        elsif name =~ /^_/
          # Hide variables that start with single underscore
          name = nil
        end

        hash[name] = instance_variable_get(var) if name
      end
      hash
    end