Utils: Add Gee.Map serialization
Signed-off-by: Vasiliy Doylov <nekocwd@mainlining.org>
This commit is contained in:
parent
87d22b312b
commit
c534d4b36a
2 changed files with 15 additions and 1 deletions
|
@ -2,4 +2,7 @@ singularity_sources += [
|
|||
'logic/utils.vala',
|
||||
]
|
||||
|
||||
singularity_deps += dependency('json-glib-1.0')
|
||||
singularity_deps += [
|
||||
dependency('json-glib-1.0'),
|
||||
dependency('gee-0.8'),
|
||||
]
|
||||
|
|
|
@ -43,4 +43,15 @@ namespace Singularity.Utils {
|
|||
warning("Object has no type to fix it");
|
||||
}
|
||||
}
|
||||
|
||||
public Json.Node serialize_string_map(Gee.Map<string, string> map) {
|
||||
var builder = new Json.Builder();
|
||||
builder.begin_object();
|
||||
foreach (var kv in map) {
|
||||
builder.set_member_name(kv.key);
|
||||
builder.add_string_value(kv.value);
|
||||
}
|
||||
builder.end_object();
|
||||
return builder.get_root();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue