Yaml parser library

Hi,

I’m developing a gnome-shell extension. I need to parse a YAML file. Is there a YAML parsing library built into Glib? I can’t find one. What other options do I have if there is no one? Gnome doesn’t use nodejs or any other browser runtime, so usage of external libraries is quite problematic as well.

Thanks

No, there is no YAML parser in GLib; and AFAIK, there are no YAML parsers that are integrated with the GNOME stack. In any case, even if there were, you would not be able to use them in a Shell extension, because it would add a system dependency.

nodejs isn’t a browser runtime, and that’s sorta the point? fwiw the JS engine used in GJS is the same as in Firefox

I mean GJS can load JS modules, or any introspected GObject library, though of course that doesn’t mean anyone has actually written what you want — and as @ebassi observed, some dependencies may or may not be suitable for use in a shell extension.

I would however be very surprised if nobody has written a JS module that can parse YAML from a string

@ebassi @zbrown Thanks for the info! I thought GJS used some custom JS engine.
There are JS yaml parsing libraries. I’m going to adopt one for my extension.

There are two options to do this in extensions:

  • Use one of the compatible opensource libraries in your extension (reference to that project and license MUST be included or your extension will be rejected).

  • Use spawn command to call the parser and get the result (for example, yq).

    In that case:

    • You MUST mention in the description that your extension is using that as a dependency.
    • You MUST check the availability of the dependency before the spawn command and show a notification if needed (with Main.notify()).
1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.