Loads a JSON stream from the content of `filename` and parses it.
If the file is large or shared between processes, [[email protected]_from_mapped_file] may be a more efficient way to load it.
See also: [[email protected]_from_data]
Example: Parser example (file):
public static int main (string[] args) {
if (args.length < 2) {
print ("Usage: test <filename.json>\n");
return -1;
}
// Load a file:
Json.Parser parser = new Json.Parser ();
try {
parser.load_from_file (args[1]);
} catch (Error e) {
print ("Unable to parse `%s': %s\n", args[1], e.message);
return -1;
}
// Get the root node:
Json.Node node = parser.get_root ();
// manipulate/read the object tree and then exit
// ...
node = null;
return 0;
}
valac --pkg json-glib-1.0 parser-example-file.vala
this |
a parser |
filename |
the path for the file to parse |
`TRUE` if the file was successfully loaded and parsed. |