Documentation
¶
Overview ¶
Do not use this package separated. It uses by smartjson and smartyaml packages It contains the common codes of that packages
Index ¶
- type SmartJsonYamlBase
- func (sjyb SmartJsonYamlBase) GetArrayByPath(path string) ([]interface{}, string)
- func (sjyb SmartJsonYamlBase) GetBoolByPath(path string) (bool, string)
- func (sjyb SmartJsonYamlBase) GetBoolByPathWithDefault(path string, def bool) bool
- func (sjyb SmartJsonYamlBase) GetCountDescendantsByPath(path string) int
- func (sjyb SmartJsonYamlBase) GetFloat64ByPath(path string) (float64, string)
- func (sjyb SmartJsonYamlBase) GetFloat64ByPathWithDefault(path string, def float64) float64
- func (sjyb SmartJsonYamlBase) GetIntegerByPath(path string) (int, string)
- func (sjyb SmartJsonYamlBase) GetIntegerByPathWithDefault(path string, def int) int
- func (sjyb SmartJsonYamlBase) GetMapByPath(path string) (map[string]interface{}, string)
- func (sjyb SmartJsonYamlBase) GetNodeByPath(path string) (interface{}, string)
- func (sjyb SmartJsonYamlBase) GetNumberByPath(path string) (float64, string)
- func (sjyb SmartJsonYamlBase) GetNumberByPathWithDefault(path string, def float64) float64
- func (sjyb SmartJsonYamlBase) GetStringByPath(path string) (string, string)
- func (sjyb SmartJsonYamlBase) GetStringByPathWithDefault(path string, def string) string
- func (sjyb SmartJsonYamlBase) GetSubtreeByPath(path string) (SmartJsonYamlBase, string)
- func (sjyb SmartJsonYamlBase) GetTimeByPath(path string) (time.Time, string)
- func (sjyb SmartJsonYamlBase) GetTimeByPathWithDefault(path string, def time.Time) time.Time
- func (sjyb SmartJsonYamlBase) JsonCompacted() (out string)
- func (sjyb SmartJsonYamlBase) JsonIndented() (out string)
- func (sjyb SmartJsonYamlBase) NodeExists(path string) bool
- func (sjyb SmartJsonYamlBase) Yaml() (out string)
- type SmartJsonYamlConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SmartJsonYamlBase ¶
type SmartJsonYamlBase struct { // ParsedData holds the unmarsaled data structures ParsedData interface{} // ParsedFrom contains the name the original form of the parsed data. "yaml" or "json" ParsedFrom string // Config holds configurable items Config SmartJsonYamlConfig }
SmartJsonYamlBase is the base structure of SmartJSON and SmartYAML The common used function connected to this structure
func (SmartJsonYamlBase) GetArrayByPath ¶
func (sjyb SmartJsonYamlBase) GetArrayByPath(path string) ([]interface{}, string)
GetArrayByPath search an array typed json/yaml node specified by the path and returns the value and the type as string
func (SmartJsonYamlBase) GetBoolByPath ¶
func (sjyb SmartJsonYamlBase) GetBoolByPath(path string) (bool, string)
GetBoolByPath search a boolean typed json/yaml node specified by the path and returns the value and the type as string
func (SmartJsonYamlBase) GetBoolByPathWithDefault ¶
func (sjyb SmartJsonYamlBase) GetBoolByPathWithDefault(path string, def bool) bool
GetBoolByPathWithDefault search a boolean typed json/yaml node specified by the path and returns the value if found, otherwise the value of def is returned without error
func (SmartJsonYamlBase) GetCountDescendantsByPath ¶
func (sjyb SmartJsonYamlBase) GetCountDescendantsByPath(path string) int
GetCountDescendantsByPath search a json/yaml node specified by the path and returns the number of descendant nodes. For a non existing node it returns zero.
func (SmartJsonYamlBase) GetFloat64ByPath ¶
func (sjyb SmartJsonYamlBase) GetFloat64ByPath(path string) (float64, string)
GetFloat64ByPath search a float64 typed json/yaml node specified by the path and returns the value and the type as string
func (SmartJsonYamlBase) GetFloat64ByPathWithDefault ¶
func (sjyb SmartJsonYamlBase) GetFloat64ByPathWithDefault(path string, def float64) float64
GetFloat64ByPathWithDefault search a float64 typed json/yaml node specified by the path and returns the value if found, otherwise the value of def is returned without error
func (SmartJsonYamlBase) GetIntegerByPath ¶
func (sjyb SmartJsonYamlBase) GetIntegerByPath(path string) (int, string)
GetIntegerByPath search a float64 typed yaml node specified by the path and returns the value and the type as string
func (SmartJsonYamlBase) GetIntegerByPathWithDefault ¶
func (sjyb SmartJsonYamlBase) GetIntegerByPathWithDefault(path string, def int) int
GetIntegerByPathWithDefault search a int typed json/yaml node specified by the path and returns the value if found, otherwise the value of def is returned without error
func (SmartJsonYamlBase) GetMapByPath ¶
func (sjyb SmartJsonYamlBase) GetMapByPath(path string) (map[string]interface{}, string)
GetMapByPath search a map typed json/yaml node specified by the path and returns the value and the type as string
func (SmartJsonYamlBase) GetNodeByPath ¶
func (sjyb SmartJsonYamlBase) GetNodeByPath(path string) (interface{}, string)
GetNodeByPath search the json/yaml node specified by the path and returns the value as interface{} and the type as string
func (SmartJsonYamlBase) GetNumberByPath ¶
func (sjyb SmartJsonYamlBase) GetNumberByPath(path string) (float64, string)
GetNumberByPath search an integer or float64 typed json/yaml node specified by the path and returns the value as float64 and the type as string
func (SmartJsonYamlBase) GetNumberByPathWithDefault ¶
func (sjyb SmartJsonYamlBase) GetNumberByPathWithDefault(path string, def float64) float64
GetNumberByPathWithDefault search a float64 or int typed json/yaml node specified by the path and returns the value if found, otherwise the value of def is returned without error
func (SmartJsonYamlBase) GetStringByPath ¶
func (sjyb SmartJsonYamlBase) GetStringByPath(path string) (string, string)
GetStringByPath search a string typed json/yaml node specified by the path and returns the value and the type as string
func (SmartJsonYamlBase) GetStringByPathWithDefault ¶
func (sjyb SmartJsonYamlBase) GetStringByPathWithDefault(path string, def string) string
GetStringByPathWithDefault search a string typed json/yaml node specified by the path and returns the value if found, otherwise the value of def is returned without error
func (SmartJsonYamlBase) GetSubtreeByPath ¶
func (sjyb SmartJsonYamlBase) GetSubtreeByPath(path string) (SmartJsonYamlBase, string)
GetSubtreeByPath returns a json/yaml subtree specified by the path Use GetSubjsonByPath or GetSubyamlByPath instead of this
func (SmartJsonYamlBase) GetTimeByPath ¶
func (sjyb SmartJsonYamlBase) GetTimeByPath(path string) (time.Time, string)
GetTimeByPath search a date or time typed yaml node specified by the path and returns the value and the type as string
func (SmartJsonYamlBase) GetTimeByPathWithDefault ¶
GetTimeByPathWithDefault search a date or time typed yaml node specified by the path and returns the value if found, otherwise the value of def is returned without error
func (SmartJsonYamlBase) JsonCompacted ¶
func (sjyb SmartJsonYamlBase) JsonCompacted() (out string)
JsonIndented generates an compacted JSON
func (SmartJsonYamlBase) JsonIndented ¶
func (sjyb SmartJsonYamlBase) JsonIndented() (out string)
JsonIndented generates an indented JSON
func (SmartJsonYamlBase) NodeExists ¶
func (sjyb SmartJsonYamlBase) NodeExists(path string) bool
NodeExists return true or false depends on the json/yaml node specified by the path is exists or not
func (SmartJsonYamlBase) Yaml ¶
func (sjyb SmartJsonYamlBase) Yaml() (out string)
Yaml generates a yaml output
type SmartJsonYamlConfig ¶
type SmartJsonYamlConfig struct { // NotFoundOrInvalidNotation contains the string which passed by query // functions as type when the requested node is not found. The default value is "none" NotFoundOrInvalidNotation string // YamlGeneratorIndenter holds the indent string used by Yaml generator function. // The indentation is only apply to maps. The default is two spaces. YamlGeneratorIndenter string // If the YamlAlwaysUseQuotesForString value is true the Yaml generator // put every string in quotes. The default is false. YamlAlwaysUseQuotesForString bool // If the OutputMapKeyOrder string array is not empty // the Yaml and Json generator functions prefers this string order in map type nodes. // This is a workaround to get rid of side effects of randomized go maps, which is used by parsers. OutputMapKeyOrder []string }
SmartJsonYamlConfig is contains configurations for SmartJSON and SmartYAML This structure is available in that stuctures with name Config
func (*SmartJsonYamlConfig) InitConfig ¶
func (conf *SmartJsonYamlConfig) InitConfig()
InitConfig sets the default values of Config