Assume the input is YAML and convert to JSON
493086
def to_json(template, clean_up=False):
    

    data = load_yaml(template)

    if clean_up:
        data = clean(data)

    return dump_json(data)
299288
def generate
      if @yaml.has_key?("version")
        @yaml = @yaml.fetch("services")
      end

      # Generate JSON for our containers.
      containers = @yaml.map do |name, fields|
        # Skip this service if we've been given a list to emit, and
        # this service isn't on the list.
        begin
          mount_points = (fields["volumes"] || []).map do |v|
            host, container, ro = v.split(':')
            {
              "sourceVolume" => path_to_vol_name(host),
              "containerPath" => container,
              "readOnly" => (ro == "ro")
            }
          end

          json = {
            "name" => name,
            "image" => fields.fetch("image"),
            # Default to a tiny guaranteed CPU share.  Currently, 2 is the
            # smallest meaningful value, and various ECS tools will round
            # smaller numbers up.
            "cpu" => fields["cpu_shares"] || 2,
            "memory" => mem_limit_to_mb(fields.fetch("mem_limit")),
            "links" => fields["links"] || [],
            "portMappings" =>
              (fields["ports"] || []).map {|pm| port_mapping(pm) },
            "essential" => true,
            "environment" => environment(fields["environment"] || {}),
            "mountPoints" => mount_points,
            "volumesFrom" => [],
            "dockerLabels" => fields.fetch("labels", {}),
          }
          if fields.has_key?("entrypoint")
            json["entryPoint"] = command_line(fields.fetch("entrypoint"))
          end
          if fields.has_key?("command")
            json["command"] = command_line(fields.fetch("command"))
          end
          if fields.has_key?("privileged")
            json["privileged"] = fields.fetch("privileged")
          end
          if fields.has_key?("ulimits")
            json["ulimits"] = fields.fetch("ulimits").map do |name, limits|
              case limits
              when Hash
                softLimit = limits.fetch("soft")
                hardLimit = limits.fetch("hard")
              else
                softLimit = limits
                hardLimit = limits
              end
              { "name" => name,
                "softLimit" => softLimit,
                "hardLimit" => hardLimit }
            end
          end
          json

        rescue KeyError => e
          # This makes it a lot easier to localize errors a bit.
          raise ContainerKeyError.new("#{e.message} processing container \"#{name}\"")
        end
      end

      # Generate our top-level volume declarations.
      volumes = @yaml.map do |name, fields|
        (fields["volumes"] || []).map {|v| v.split(':')[0] }
      end.flatten.sort.uniq.map do |host_path|
        {
          "name" => path_to_vol_name(host_path),
          "host" => { "sourcePath" => host_path }
        }
      end

      # Return our final JSON.
      {
        "family" => @family,
        "containerDefinitions" => containers,
        "volumes" => volumes
      }
    end
650719
def parse_yaml(self, y):
        '''

        '''
        super(WaitTime, self).parse_yaml(y)
        self.wait_time = int(y['condition']['waitTime']['waitTime'])
        return self
1107714
def to_yaml(self):
        """"""
        import yaml

        with self.__reference__.open('w') as fp:
            yaml.dump(self.asjsonld(), fp, default_flow_style=False)
1132403
def load(stream, fmt='lha'):
    """"""
    if fmt == 'lha':
        return pylha.load(stream)
    elif fmt == 'json':
        if isinstance(stream, str):
            return json.loads(stream)
        else:
            return json.load(stream)
    elif fmt == 'yaml':
        return yaml.load(stream)
1245981
def parse_yaml_file(self, path):
        """"""
        with open(path, 'r') as fp:
            data = yaml.safe_load(fp)

        if not data:
            return {}

        def traverse(namespace, d):
            cfg = {}
            for key, val in d.items():
                if isinstance(d[key], dict):
                    cfg.update(traverse(namespace + [key], d[key]))
                else:
                    if not isinstance(val, str):
                        # All values should be double-quoted strings so they
                        # parse as strings; anything else is a configuration
                        # error at parse-time
                        raise ConfigurationError(
                            'Invalid value %r in file %s: values must be double-quoted strings' % (
                                val, path
                            )
                        )

                    cfg['_'.join(namespace + [key]).upper()] = val

            return cfg

        return traverse([], data)
509541
def parse_yaml(self, y):
        '''

        '''
        super(TargetExecutionContext, self).parse_yaml(y)
        if 'id' in y:
            self.id = y['id']
        else:
            self.id = ''
        return self
106899
def dump(d, fmt='json', stream=None):
    
    if fmt == 'json':
        return _dump_json(d, stream=stream)
    elif fmt == 'yaml':
        return yaml.dump(d, stream)
    elif fmt == 'lha':
        s = _dump_lha(d)
        if stream is None:
            return s
        else:
            return stream.write(s)
516417
def to_yaml(cls, representer, node):
        """"""
        return representer.represent_scalar(cls.yaml_tag, node.value)
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)
685473
def generate_from_yaml(pseudo_ast, language):
    '''
    

    '''
    return pseudo.generate(pseudo.loader.as_tree(pseudo_ast), language)
435930
def yaml_to_param(obj, name):
	
	return from_pyvalue(u"yaml:%s" % name, unicode(yaml.dump(obj)))
97557
function yrequire(filename) {
	const s = fs.readFileSync(filename,'utf8');
	return yaml.safeLoad(s,{json:true});
}
645721
def write_yaml (self, data, encoding=None, errors=None, newline=None, **kwargs):
        
        import yaml

        with self.open (mode='wt', encoding=encoding, errors=errors, newline=newline) as f:
            return yaml.dump (data, stream=f, **kwargs)
1205316
function stringYAML2JSON (doc, compact = false) {
  if (!doc || typeof doc !== 'string') {
    throw new TypeError('Argument must be a string or object, and not empty: ' + doc)
  }

  let obj = yaml.safeLoad(doc)

  if (!obj || typeof obj !== 'object') {
    throw new TypeError('Argument must be in yaml format: ' + doc)
  }

  return JSON.stringify(obj, undefined, compact ? undefined : 2)
}
34773
def yml_dump(data, stream, yml_fnc=yml_fnc, **options):
    
    _is_dict = anyconfig.utils.is_dict_like(data)

    if options.get("ac_safe", False):
        options = {}
    elif not options.get("Dumper", False) and _is_dict:
        # TODO: Any other way to get its constructor?
        maybe_container = options.get("ac_dict", type(data))
        options["Dumper"] = _customized_dumper(maybe_container)

    if _is_dict:
        # Type information and the order of items are lost on dump currently.
        data = anyconfig.dicts.convert_to(data, ac_dict=dict)
        options = common.filter_from_options("ac_dict", options)

    return yml_fnc("dump", data, stream, **options)
1201359
function view_json(req, src, options, end) {
    load(src
        , {
            authorization: req.headers['authorization'],
            X_Forwarded_For: req.X_Forwarded_For
        }

        , function(status, result) {
            if (status !== true) {
                return end(false, 'status > ' + status);
            };

            result.get(['json'], function(status, data) {
                if (status == true) {
                    if (options.yaml) {
                        data = yaml.safeDump(data, {indent: options.yaml});
                    } else {
                        data = JSON.stringify(data, null, "\t");
                    };

                } else {
                    data = 'status > ' + status;
                };

                end(status, data);
            });
        }
    );
}