// ParseJSONFile - Read a file and convert into a representation of the parsed JSON.
1532
func ParseJSONFile(path string) (*Container, error) {
	if len(path) > 0 {
		cBytes, err := ioutil.ReadFile(path)
		if err != nil {
			return nil, err
		}

		container, err := ParseJSON(cBytes)
		if err != nil {
			return nil, err
		}

		return container, nil
	}
	return nil, ErrInvalidPath
}
1100604
func (ini *INI) ParseFile(filename string) error {
    contents, err := ioutil.ReadFile(filename)
    if err != nil {
        return err
    }
    ini.parseSection = true
    ini.skipCommits = true
    return ini.parseINI(contents, DefaultLineSeparator, DefaultKeyValueSeparator)
}
839316
func JSONLoad(filename string, data interface{}) error {
	file, err := os.Open(filename + ".gz")
	defer file.Close()
	if err != nil {
		return err
	}
	gz, err := gzip.NewReader(file)
	if err != nil {
		return err
	}
	blob, err := ioutil.ReadAll(gz)
	if err != nil {
		return err
	}
	err = json.Unmarshal(blob, data)
	if err != nil {
		return err
	}
	return nil
}
923585
func EnvFileToJSONFile(data interface{}, filepathENV, filepathJSON string, perm os.FileMode, prefix, indent string) error {
	err := godotenv.Load(filepathENV)
	if err != nil {
		return err
	}

	err = env.Parse(data)
	if err != nil {
		return err
	}

	return iom.WriteFileJSON(filepathJSON, data, perm, prefix, indent)
}
1290559
func LoadFile(filename string) (*File, error) {
	// check if the file exists, return a new file if it doesn't
	if _, err := os.Stat(filename); os.IsNotExist(err) {
		file := NewFile()
		file.Filename = filename
		return file, nil
	}

	// if file exists, read and parse it
	f, err := os.Open(filename)
	if err != nil {
		return nil, err
	}
	defer f.Close()

	return Parse(filename, filename, f)
}
973999
func ReadJSON(filePath string) GossConfig {
	file, err := ioutil.ReadFile(filePath)
	if err != nil {
		fmt.Printf("File error: %v\n", err)
		os.Exit(1)
	}

	return ReadJSONData(file, false)
}
1295372
func DecodeFile(fileName string) (image.Image, string, error) {
	file, err := os.Open(fileName)
	if err != nil {
		return nil, "", fmt.Errorf("%s: %s", fileName, err)
	}

	img, fm, err := image.Decode(file)
	if err != nil {
		return nil, fm, fmt.Errorf("%s: %s", fileName, err)
	}

	return img, fm, nil
}
798652
func ParseJSONFromUTF8(json []byte, options ...ParserOptions) (Slice, error) {
	return ParseJSON(bytes.NewReader(json), options...)
}
461738
func parse_json(data []rune) (Value, int, error) {
	var (
		cs int
		p int
		pe int = len(data)
		eof int = len(data)
	)
	var ret Value


//line ucl.go:1026
	{
	cs = document_start
	}

//line ucl.rl:279

//line ucl.go:1033
	{
	var _klen int
	var _trans int
	var _acts int
	var _nacts uint
	var _keys int
	if p == pe {
		goto _test_eof
	}
	if cs == 0 {
		goto _out
	}
_resume:
	_keys = int(_document_key_offsets[cs])
	_trans = int(_document_index_offsets[cs])

	_klen = int(_document_single_lengths[cs])
	if _klen > 0 {
		_lower := int(_keys)
		var _mid int
		_upper := int(_keys + _klen - 1)
		for {
			if _upper < _lower {
				break
			}

			_mid = _lower + ((_upper - _lower) >> 1)
			switch {
			case data[p] < _document_trans_keys[_mid]:
				_upper = _mid - 1
			case data[p] > _document_trans_keys[_mid]:
				_lower = _mid + 1
			default:
				_trans += int(_mid - int(_keys))
				goto _match
			}
		}
		_keys += _klen
		_trans += _klen
	}

	_klen = int(_document_range_lengths[cs])
	if _klen > 0 {
		_lower := int(_keys)
		var _mid int
		_upper := int(_keys + (_klen << 1) - 2)
		for {
			if _upper < _lower {
				break
			}

			_mid = _lower + (((_upper - _lower) >> 1) & ^1)
			switch {
			case data[p] < _document_trans_keys[_mid]:
				_upper = _mid - 2
			case data[p] > _document_trans_keys[_mid + 1]:
				_lower = _mid + 2
			default:
				_trans += int((_mid - int(_keys)) >> 1)
				goto _match
			}
		}
		_trans += _klen
	}

_match:
	cs = int(_document_trans_targs[_trans])

	if _document_trans_actions[_trans] == 0 {
		goto _again
	}

	_acts = int(_document_trans_actions[_trans])
	_nacts = uint(_document_actions[_acts]); _acts++
	for ; _nacts > 0; _nacts-- {
		_acts++
		switch _document_actions[_acts-1] {
		case 0:
//line ucl.rl:23

		return nil, -1, fmt.Errorf("parse error at byte %d (state=%d)", p, cs)
	
		case 1:
//line ucl.rl:245

		v, newp, err := parse_object(data, p, pe);
		if err != nil { return nil, -1, err };
		ret = v;
		p = ( newp) - 1

	
		case 2:
//line ucl.rl:252

		v, newp, err := parse_array(data, p, pe);
		if err != nil { return nil, -1, err };
		ret = v;
		p = ( newp) - 1

	
//line ucl.go:1134
		}
	}

_again:
	if cs == 0 {
		goto _out
	}
	p++
	if p != pe {
		goto _resume
	}
	_test_eof: {}
	if p == eof {
		__acts := _document_eof_actions[cs]
		__nacts := uint(_document_actions[__acts]); __acts++
		for ; __nacts > 0; __nacts-- {
			__acts++
			switch _document_actions[__acts-1] {
			case 0:
//line ucl.rl:23

		return nil, -1, fmt.Errorf("parse error at byte %d (state=%d)", p, cs)
	
//line ucl.go:1158
			}
		}
	}

	_out: {}
	}

//line ucl.rl:280

	return ret, -1, nil
}
284423
func ParseJSONFromString(json string, options ...ParserOptions) (Slice, error) {
	return ParseJSON(strings.NewReader(json), options...)
}
279494
func (c *Client) ReadJSON(v interface{}) (err error) {
	_, r, err := c.NextReader()
	if err != nil {
		return err
	}
	return codec.NewDecoder(r, &jh).Decode(v)
}
599210
func ReadSpecificDockerConfigJsonFile(filePath string) (cfg DockerConfig, err error) {
	var contents []byte

	if contents, err = ioutil.ReadFile(filePath); err != nil {
		return nil, err
	}
	return readDockerConfigJsonFileFromBytes(contents)
}
323427
func parseJSON(input []byte) (*logEntry, error) {
	var raw map[string]interface{}
	entry := &logEntry{}

	err := json.Unmarshal(input, &raw)
	if err != nil {
		return nil, err
	}

	// Parse hclog-specific objects
	if v, ok := raw["@message"]; ok {
		entry.Message = v.(string)
		delete(raw, "@message")
	}

	if v, ok := raw["@level"]; ok {
		entry.Level = v.(string)
		delete(raw, "@level")
	}

	if v, ok := raw["@timestamp"]; ok {
		t, err := time.Parse("2006-01-02T15:04:05.000000Z07:00", v.(string))
		if err != nil {
			return nil, err
		}
		entry.Timestamp = t
		delete(raw, "@timestamp")
	}

	// Parse dynamic KV args from the hclog payload.
	for k, v := range raw {
		entry.KVPairs = append(entry.KVPairs, &logEntryKV{
			Key:   k,
			Value: v,
		})
	}

	return entry, nil
}
1044743
func ParseFile(filePath string, root Root) error {
	workDir, fileName := filepath.Split(filePath)
	_, err := ParseReadFile(workDir, fileName, root)
	return err
}
1070696
func (o *ManagedFile) UnmarshalJSON(data []byte) error {
	var jsonName string
	if err := json.Unmarshal(data, &jsonName); err == nil {
		o.Name = &jsonName
		return nil
	}

	var r realManagedFile
	if err := json.Unmarshal(data, &r); err != nil {
		return err
	}
	*o = ManagedFile(r)
	return nil
}
1049928
func (po *Po) ParseFile(f string) {
	// Check if file exists
	info, err := os.Stat(f)
	if err != nil {
		return
	}

	// Check that isn't a directory
	if info.IsDir() {
		return
	}

	// Parse file content
	data, err := ioutil.ReadFile(f)
	if err != nil {
		return
	}

	po.Parse(data)
}
1295341
func ParseFile(path string) (*Template, error) {
	var f *os.File
	var err error
	if path == "-" {
		// Create a temp file for stdin in case of errors
		f, err = tmp.File("parse")
		if err != nil {
			return nil, err
		}
		defer os.Remove(f.Name())
		defer f.Close()
		io.Copy(f, os.Stdin)
		f.Seek(0, os.SEEK_SET)
	} else {
		f, err = os.Open(path)
		if err != nil {
			return nil, err
		}
		defer f.Close()
	}
	tpl, err := Parse(f)
	if err != nil {
		syntaxErr, ok := err.(*json.SyntaxError)
		if !ok {
			return nil, err
		}
		// Rewind the file and get a better error
		f.Seek(0, os.SEEK_SET)
		// Grab the error location, and return a string to point to offending syntax error
		line, col, highlight := highlightPosition(f, syntaxErr.Offset)
		err = fmt.Errorf("Error parsing JSON: %s\nAt line %d, column %d (offset %d):\n%s", err, line, col, syntaxErr.Offset, highlight)
		return nil, err
	}

	if !filepath.IsAbs(path) {
		path, err = filepath.Abs(path)
		if err != nil {
			return nil, err
		}
	}

	tpl.Path = path
	return tpl, nil
}