]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
man: add brief intro page to new sd-json APIs
authorLennart Poettering <lennart@poettering.net>
Thu, 2 May 2024 12:44:37 +0000 (14:44 +0200)
committerLennart Poettering <lennart@poettering.net>
Wed, 12 Jun 2024 16:42:22 +0000 (18:42 +0200)
man/libsystemd.xml
man/rules/meson.build
man/sd-json.xml [new file with mode: 0644]

index 34bd62ed52cc2ec0c8815afc93127c0afb027cc1..d3d9798d6bba8ea926ac333e0bd500030072335f 100644 (file)
@@ -24,8 +24,6 @@
   <refsynopsisdiv>
     <programlisting>
 #include &lt;systemd/sd-bus.h&gt;
-#include &lt;systemd/sd-bus-vtable.h&gt;
-#include &lt;systemd/sd-bus-protocol.h&gt;
 #include &lt;systemd/sd-daemon.h&gt;
 #include &lt;systemd/sd-device.h&gt;
 #include &lt;systemd/sd-event.h&gt;
@@ -33,6 +31,7 @@
 #include &lt;systemd/sd-hwdb.h&gt;
 #include &lt;systemd/sd-id128.h&gt;
 #include &lt;systemd/sd-journal.h&gt;
+#include &lt;systemd/sd-json.h&gt;
 #include &lt;systemd/sd-login.h&gt;
 #include &lt;systemd/sd-messages.h&gt;
 #include &lt;systemd/sd-path.h&gt;
@@ -61,6 +60,7 @@
     <citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
     <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
     <citerefentry><refentrytitle>sd-journal</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
+    <citerefentry><refentrytitle>sd-json</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
     and
     <citerefentry><refentrytitle>sd-login</refentrytitle><manvolnum>3</manvolnum></citerefentry>
     for information about different parts of the library interface.</para>
index c3e1eefd8a39987f84398925b6da1cf2cf184389..9b8a29c5647f5ab685ddd8eb17c59b7ffb82d112 100644 (file)
@@ -151,6 +151,7 @@ manpages = [
    'sd_id128_t'],
   ''],
  ['sd-journal', '3', [], ''],
+ ['sd-json', '3', [], ''],
  ['sd-login', '3', [], 'HAVE_PAM'],
  ['sd_booted', '3', [], ''],
  ['sd_bus_add_match',
diff --git a/man/sd-json.xml b/man/sd-json.xml
new file mode 100644 (file)
index 0000000..e10ef0d
--- /dev/null
@@ -0,0 +1,91 @@
+<?xml version='1.0'?> <!--*-nxml-*-->
+<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
+  "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
+<!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
+
+<refentry id="sd-json"
+  xmlns:xi="http://www.w3.org/2001/XInclude">
+
+  <refentryinfo>
+    <title>sd-json</title>
+    <productname>systemd</productname>
+  </refentryinfo>
+
+  <refmeta>
+    <refentrytitle>sd-json</refentrytitle>
+    <manvolnum>3</manvolnum>
+  </refmeta>
+
+  <refnamediv>
+    <refname>sd-json</refname>
+    <refpurpose>APIs for Dealing with JSON Objects</refpurpose>
+  </refnamediv>
+
+  <refsynopsisdiv>
+    <funcsynopsis>
+      <funcsynopsisinfo>#include &lt;systemd/sd-json.h&gt;</funcsynopsisinfo>
+    </funcsynopsis>
+
+    <cmdsynopsis>
+      <command>pkg-config --cflags --libs libsystemd</command>
+    </cmdsynopsis>
+  </refsynopsisdiv>
+
+  <refsect1>
+    <title>Description</title>
+
+    <para><filename>sd-json.h</filename> is part of
+    <citerefentry><refentrytitle>libsystemd</refentrytitle><manvolnum>3</manvolnum></citerefentry> and
+    provides APIs to parse, generate, format and otherwise operate with JSON objects.</para>
+
+    <para>The API's central data structure is <type>JsonVariant</type> which encapsulates a JSON object,
+    array, string, boolean, number or null value. These data structures are mostly considered immutable after
+    construction (i.e. their contents won't change, but some meta-data might, such as reference counters).</para>
+
+    <para>The APIs broadly fall into five categories:</para>
+
+    <itemizedlist>
+      <listitem><para>APIs to directly operate with <type>JsonVariant</type> objects, in the
+      <function>sd_json_variant*</function> namespace.</para></listitem>
+
+      <listitem><para>APIs to construct complex JSON objects, in the <function>sd_json_build*</function>
+      namespace.</para></listitem>
+
+      <listitem><para>APIs to map <type>JsonVariant</type> objects and their fields to matching fields in C
+      structures, in the <function>sd_json_dispatch*</function> namespace.</para></listitem>
+
+      <listitem><para>APIs to convert a string representation of a JSON object into a
+      <type>JsonVariant</type> object, in the <function>sd_json_parse*</function>
+      namespace.</para></listitem>
+
+      <listitem><para>APIs to convert an <type>JsonVariant</type> object into its string representation, in
+      the <function>sd_json_format*</function> namespace.</para></listitem>
+    </itemizedlist>
+
+    <para>This JSON library will internally encode JSON integer numbers in the range
+    <constant>INT64_MIN</constant>…<constant>UINT64_MAX</constant> into native 64bit signed or unsigned
+    integers, and will reproduce them without loss of precision. Non-integer numbers are stored in 64bit IEEE
+    floating point numbers.</para>
+
+    <para>If the functions return string arrays, these are generally
+    <constant>NULL</constant> terminated and need to be freed by the
+    caller with the libc
+    <citerefentry project='man-pages'><refentrytitle>free</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    call after use, including the strings referenced therein.
+    Similarly, individual strings returned need to be freed, as
+    well.</para>
+
+    <para>As a special exception, instead of an empty string array <constant>NULL</constant> may be returned,
+    which should be treated equivalent to an empty string array.</para>
+  </refsect1>
+
+  <xi:include href="libsystemd-pkgconfig.xml" />
+
+  <refsect1>
+    <title>See Also</title>
+    <para><simplelist type="inline">
+      <member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>,
+      <member><citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry></member>
+    </simplelist></para>
+  </refsect1>
+</refentry>