// Reads json file returning GossConfig
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)
}
671541
func readJson(resp *http.Response, result interface{}) (err error) {
	defer drainAndClose(resp.Body, &err)
	decoder := json.NewDecoder(resp.Body)
	return decoder.Decode(result)
}
1077585
func (m *Message) ReadJSON(v interface{}) error {
	return json.Unmarshal(m.Body, v)
}
851107
func ReadJSONConfigFromFile(filename string, argv interface{}) error {
	file, err := os.Open(filename)
	if err == nil {
		defer file.Close()
		err = ReadJSON(file, argv)
	} else {
		exe, e := os.Executable()
		if e != nil {
			return e
		}
		// allow self-config .json files to go with the executable file, #40
		file, err = os.Open(filepath.Dir(exe) + string(filepath.Separator) + filename)
		if err == nil {
			defer file.Close()
			err = ReadJSON(file, argv)
		}
	}
	return err
}
647941
func ReadFromString(configString string) (*FileConfig, error) {
	data, err := base64.StdEncoding.DecodeString(configString)
	if err != nil {
		return nil, trace.BadParameter(
			"confiugraion should be base64 encoded: %v", err)
	}
	return ReadConfig(bytes.NewBuffer(data))
}
278095
func readFile(filename string) *config {
	verboseMsg("Reading configuration " + filename)
	data, err := ioutil.ReadFile(filename)
	if err != nil {
		panic(StatusError{err, 74})
	}

	ext := filepath.Ext(filename)
	return unmarshal(data, ext)
}
967216
func ApplyJsonConfigFile(file string) error {
	bin, err := ioutil.ReadFile(file)
	if err != nil {
		return err
	}
	decoder := json.NewDecoder(bytes.NewBuffer(bin))
	decoder.UseNumber()
	var conf Conf
	if err = decoder.Decode(&conf); err != nil {
		return err
	}
	return DictConfig(&conf)
}
556499
func ReadJSON(fs filesystem.Filespace, src string, object interface{}) error {
	jsonb, err := fs.ReadFile(src)
	if err != nil {
		return err
	}
	return varutil.ObjectFromJSON(object, string(jsonb))
}
164972
func (c *Conn) ReadJSON(v interface{}) error {
	_, r, err := c.NextReader()
	if err != nil {
		return err
	}
	err = json.NewDecoder(r).Decode(v)
	if err == io.EOF {
		// One value is expected in the message.
		err = io.ErrUnexpectedEOF
	}
	return err
}
9566
func ReadSpecific(filename string, configObject interface{}) error {
	fileContents, err := ioutil.ReadFile(filename)

	if err == nil {
		json.Unmarshal(fileContents, &configObject)
	}

	return err
}
787434
func ReadJSON(path string, s interface{}) error {
	dat, err1 := ioutil.ReadFile(path)
	if err1 != nil {
		return err1
	}
	return json.Unmarshal(dat, s)
}
1201777
func ReadJSONData(data []byte, detectFormat bool) GossConfig {
	if TemplateFilter != nil {
		data = TemplateFilter(data)
		if debug {
			fmt.Println("DEBUG: file after text/template render")
			fmt.Println(string(data))
		}
	}
	format := OutStoreFormat
	if detectFormat == true {
		format = getStoreFormatFromData(data)
	}
	gossConfig := NewGossConfig()
	// Horrible, but will do for now
	if err := unmarshal(data, gossConfig, format); err != nil {
		// FIXME: really dude.. this is so ugly
		fmt.Printf("Error: %v\n", err)
		os.Exit(1)
	}
	return *gossConfig
}
226963
func ReadJSON(r *http.Request, val interface{}) error {
	data, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return trace.Wrap(err)
	}
	if err := json.Unmarshal(data, &val); err != nil {
		return trace.BadParameter("request: %v", err.Error())
	}
	return nil
}
291473
func Read(path string, v interface{}, schema string) []serror.SnapError {
	// read bytes from file
	b, err := cfgReader.ReadFile(path)
	if err != nil {
		return []serror.SnapError{serror.New(err)}
	}
	b = []byte(os.ExpandEnv(string(b)))
	// convert from YAML to JSON (remember, JSON is actually valid YAML)
	jb, err := yaml.YAMLToJSON(b)
	if err != nil {
		return []serror.SnapError{serror.New(fmt.Errorf("error converting YAML to JSON: %v", err))}
	}
	// validate the resulting JSON against the input the schema
	if errors := cfgValidator.validateSchema(schema, string(jb)); errors != nil {
		// if invalid, construct (and return?) a SnapError from the errors identified
		// during schema validation
		return errors
	}
	// if valid, parse the JSON byte-stream (above)
	if parseErr := json.Unmarshal(jb, v); parseErr != nil {
		// remove any YAML-specific prefix that might have been added by then
		// yaml.Unmarshal() method or JSON-specific prefix that might have been
		// added if the resulting JSON string could not be marshalled into our
		// input interface correctly (note, if there is no match to either of
		// these prefixes then the error message will be passed through unchanged)
		tmpErr := strings.TrimPrefix(parseErr.Error(), "error converting YAML to JSON: yaml: ")
		errRet := strings.TrimPrefix(tmpErr, "error unmarshaling JSON: json: ")
		return []serror.SnapError{serror.New(fmt.Errorf("Error while parsing configuration file: %v", errRet))}
	}
	return nil
}
1087727
func (c *Config) UnmarshalJSON(data []byte) error {
	// construct a map of strings to json.RawMessages (to defer the parsing of individual
	// fields from the unmarshalled interface until later), then unmarshal the input
	// byte array into that map
	t := make(map[string]json.RawMessage)
	if err := json.Unmarshal(data, &t); err != nil {
		return err
	}
	// loop through the individual map elements, parse each in turn, and set
	// the appropriate field in this configuration
	for k, v := range t {
		switch k {
		case "log_level":
			if err := json.Unmarshal(v, &(c.LogLevel)); err != nil {
				return fmt.Errorf("%v (while parsing 'log_level')", err)
			}
		case "gomaxprocs":
			if err := json.Unmarshal(v, &(c.GoMaxProcs)); err != nil {
				return fmt.Errorf("%v (while parsing 'gomaxprocs')", err)
			}
		case "log_path":
			if err := json.Unmarshal(v, &(c.LogPath)); err != nil {
				return fmt.Errorf("%v (while parsing 'log_path')", err)
			}
		case "log_truncate":
			if err := json.Unmarshal(v, &(c.LogTruncate)); err != nil {
				return fmt.Errorf("%v (while parsing 'log_truncate')", err)
			}
		case "log_colors":
			if err := json.Unmarshal(v, &(c.LogColors)); err != nil {
				return fmt.Errorf("%v (while parsing 'log_colors')", err)
			}
		case "control":
			if err := json.Unmarshal(v, c.Control); err != nil {
				return err
			}
		case "restapi":
			if err := json.Unmarshal(v, c.RestAPI); err != nil {
				return err
			}
		case "scheduler":
			if err := json.Unmarshal(v, c.Scheduler); err != nil {
				return err
			}
		case "tribe":
			if err := json.Unmarshal(v, c.Tribe); err != nil {
				return err
			}
		default:
			return fmt.Errorf("Unrecognized key '%v' in global config file", k)
		}
	}
	return nil
}
313285
func ReadJSONFromFile(filename string, argv interface{}) error {
	file, err := os.Open(filename)
	if err == nil {
		defer file.Close()
		err = ReadJSON(file, argv)
	}
	return err
}
1284657
func (BasePage) ReadSettings(c context.Context) (map[string]string, error) {
	return nil, nil
}