gura #
V Gura
vlang.io | Docs | Changelog | Contributing
>>> import gura { raw_parse, raw_encode }
>>> data := raw_parse('text: "Hello World!"') ?
>>> println(data)
{'text': gura.Any('Hello World!')}
>>> raw_encode(data)
text: "Hello World!"
Installation
Via vpm
$ v install gura
Via vpkg
$ vpkg get https://github.com/gura-conf/vgura
Done. Installation completed.
Testing
To test the module, just type the following command:
$ ./bin/test # execute `./bin/test -h` to know more about the test command
License
Contributors
Made with contributors-img.
Constants #
const (
null = Null{}
)
const (
version = '0.1.10'
)
fn encode #
fn encode[T](typ T) string
encode is a generic function that encodes a type into a gura string.
fn parse #
fn parse[T](src string) ?T
parse is a generic function that parses a gura string into the target type.
fn raw_encode #
fn raw_encode(data map[string]Any) string
raw_encode generates a Gura string from a dictionary
fn raw_parse #
fn raw_parse(text string) ?map[string]Any
raw_parse parses a text in Gura format
interface Serializable #
interface Serializable {
from_gura(f map[string]Any)
to_gura() map[string]Any
}
fn ([]Any) as_strings #
fn (a []Any) as_strings() []string
type Any #
type Any = Null
| []Any
| bool
| f32
| f64
| i16
| i64
| i8
| int
| map[string]Any
| string
| u16
| u32
| u64
| u8
Any
is a sum type that lists the possible types to be decoded and used.
fn (Any) to_json #
fn (a Any) to_json() string
to_json returns Any
as a JSON encoded string.
fn (Any) str #
fn (f Any) str() string
str returns the string representation of the Any
type.
fn (Any) as_map #
fn (f Any) as_map() map[string]Any
as_map uses Any
as a map.
fn (Any) string #
fn (a Any) string() string
string returns Any
as a string.
fn (Any) int #
fn (f Any) int() int
int uses Any
as an integer.
fn (Any) i64 #
fn (f Any) i64() i64
i64 uses Any
as a 64-bit integer.
fn (Any) u64 #
fn (f Any) u64() u64
u64 uses Any
as a 64-bit unsigned integer.
fn (Any) f32 #
fn (f Any) f32() f32
f32 uses Any
as a 32-bit float.
fn (Any) f64 #
fn (f Any) f64() f64
f64 uses Any
as a float.
fn (Any) arr #
fn (f Any) arr() []Any
arr uses Any
as an array.
fn (Any) bool #
fn (f Any) bool() bool
bool uses Any
as a bool
fn (map[string]Any) value #
fn (m map[string]Any) value(key string) ?Any
fn (map[string]Any) to_json #
fn (a map[string]Any) to_json() string
to_json returns Any
as a JSON encoded string.
struct DuplicatedImportError #
struct DuplicatedImportError {
Error
pub:
msg string
}
fn (DuplicatedImportError) msg #
fn (err &DuplicatedImportError) msg() string
struct DuplicatedVariableError #
struct DuplicatedVariableError {
Error
pub:
msg string
}
fn (DuplicatedVariableError) msg #
fn (err &DuplicatedVariableError) msg() string
struct FileNotFoundError #
struct FileNotFoundError {
Error
pub:
msg string
}
fn (FileNotFoundError) msg #
fn (err &FileNotFoundError) msg() string
struct InvalidIndentationError #
struct InvalidIndentationError {
Error
pub:
msg string
}
fn (InvalidIndentationError) msg #
fn (err &InvalidIndentationError) msg() string
struct Null #
struct Null {}
Null
struct is a simple representation of the null
value in GURA.
fn (Null) str #
fn (_ Null) str() string
struct ParseError #
struct ParseError {
Error
pub:
msg string
line int
pos int
}
fn (ParseError) msg #
fn (err &ParseError) msg() string
struct VariableNotDefinedError #
struct VariableNotDefinedError {
Error
pub:
key string
msg string
}
fn (VariableNotDefinedError) msg #
fn (err &VariableNotDefinedError) msg() string
- README
- Constants
- fn encode
- fn parse
- fn raw_encode
- fn raw_parse
- interface Serializable
- type []Any
- type Any
- type map[string]Any
- struct DuplicatedImportError
- struct DuplicatedVariableError
- struct FileNotFoundError
- struct InvalidIndentationError
- struct Null
- struct ParseError
- struct VariableNotDefinedError