Commit 72bf6249 authored by Jeremy Bicha's avatar Jeremy Bicha

New upstream version 1.4.2

parents e0503b0a 68e90daf
This diff is collapsed.
Overview of changes for 1.4
• Use Meson as the only build system
• #773504 - Avoid extra allocations [Garrett Regier]
• #780550 - meson error looking for python3 [Daniele Forghieri]
• #769206 - docs: Clarify when NULL might be returned [Matthew Leeds]
• #766281 - utils/json_from_string: Don't reset user-provided error
argument [Heinrich Fink]
• #758580 - json_reader_is_value returns TRUE for null type but
json_reader_get_value throws an error [Robert Ancell]
• #768788 - Incorrect account of jsonPath syntax in doc [Allin Cottrell]
• #774688 - json_from_string() could be optimized to avoid copying the
root node [Ole André Vadla Ravnås]
Overview of changes for 1.2
• Add simple wrapper functions for JsonGenerator and JsonParser to
write and read a string from and to a JsonNode, respectively
• Drop use of deprecated GIO API
• Bump the dependency on GLib to 2.46
• Do not create `null` nodes for empty strings [#730803]
• Documentation fixes [Philip Withnall - #754384]
• Avoid crashes in the test suite [Iain Lane - #755977]
• Add simple iterator object for JSON objects [Philip Withnall - #755509]
• Detect missing commas in arrays
• Add support for g_auto* macros
• Allow making JSON types optionally immutable, in order to allow
efficient hashing and equality tests [Philip Withnal - #756121]
• Improve the build under MSVC [Chun-wei Fan]
• Add Meson build system [Thibault Saunier - #773603]
• Support Visual Studio 2017 [Chun-wei Fan]
• Allow using G_DECLARE_INTERFACE with JsonSerializable
• Allow empty strings as JsonObject member names [Dr. David Alan Gilbert - #747279]
Overview of changes for 1.0
• Bump the dependency on GLib to 2.38
• Use the TAP driver for the test suite
• Improve the syntax validation in JsonPath
• Validate the JsonParser input to be UTF-8
• Add command line tools for validating and formatting JSON
• Improve documentation
Overview of changes for 0.16.0
• Fixes for building with VisualStudio. [Chun-wei Fan]
• Allow out-of-tree builds. [Colin Walters]
• Bump the dependency on GLib to 2.31.
• Use the new deprecation system provided by GLib.
• Simplify the value handling inside JsonNode.
• Use lcov to generate coverage reports for the test suite.
• Check expected ABI when building.
• Drop dependency on when building from Git.
Overview of changes for 0.14.0
• Documentation fixes
• Bump the dependency on GLib to 2.26
• Allow building on Windows using VisualStudio [Chun-wei Fan]
• Add JSON ↔ GVariant translation [Eduardo Lima Mitev]
• Improve sanity checks when (de)serializing GObject
properties [Tristan Van Berkom]
• Add missing introspection annotations [Luca Bruno]
• Add JsonReader.list_members()
• Allow using JsonReader.read_element() on JSON objects
• Remove all G_CONST_RETURN usage after the deprecation
• Allow JsonSerializable to override the introspection and
modification of properties
• Add i18n support for GError messages
• Do not serialize GObject properties that match their default
• Make JsonReader perform a stricter validation especially when using
the strongly typed accessors.
Overview of changes for 0.12.0
• Support surrogate pairs in JSON strings [Eiichi Sato]
• Update the test suite
• Add (optional) coverage reports
• Improve strictness of JsonParser
• Improve error reporting of JsonParser
• Add JsonBuilder, a convenience API for programmatic building
of JSON trees [Luca Bruno]
• Add methods for JsonParser and JsonGenerator to handle Input|OutputStream
objects coming from GIO.
• Add JsonReader, a convenience API for cursor-based parsing of
JSON trees
• Depend on GObject-Introspection ≥ 0.9.5
Overview of changes for 0.10.0
• Fix generation of doubles [Cornelius Hald]
• Add more units to the test suite
• Add JsonNode macros for quick type checking
• Guarantee insertion order when parsing and generating JSON Objects
• Serialize GParamSpecObject properties
• Add serialization and deserialization for GBoxed types
• Add API for serializing GObjects to, and deserializing from, JsonNode
• Build environment fixes
• Documentation fixes
• Generate correct introspection data
• Make JsonSerializable in complete control of deserialization [Tristan Van
Overview of changes for 0.8.0
* Remove the in-tree Vala bindings: they are part of Vala, now
* Remove the in-tree Debian packaging
* Fix bug #958: JsonGenerator does not escape special characters
* Fix bug #965: Conditionally compile the test suite
* Display the filename and line inside the error messages when
loading from a file
* Fix bug #1203: Correctly terminate a string array
* Fix bug #1393: Regression tests fail on OpenBSD
* Do not leak memory on error code paths
* Improve and clean up the build system
* Make JsonNode completely opaque
* Conditionally generate introspection data on build
* Fix bug #1353: Do not overwrite when copying
* Deprecate json_object_add_member()
* Add convenience accessors for JsonObject and JsonArray
* Add convenience iteration functions for JsonObject and JsonArray
* Automatically promote integers to gint64, to compensate for the
lack of integer size in the JSON specificiation
* Disallow the inclusion of single header files: only json-glib,h
and json-gobject.h can be included directly
* Documentation fixes
* Clean up and remove code duplication inside the Parser object
Overview of changes for 0.6.0
* Allow deserialization of strings into enum and flag types
* Add the :indent-char property to JsonGenerator
* Add functions to retrieve copies of the nodes inside Object and Array
* Fix leaks and invalid accesses
* Use the right type for the buffer length parameter in JsonParser
* Provide a default implementation for JsonSerializable
* Provide our own JSON tokenizer (using GScanner) for the JSON-only
features that would have been lost by using GScanner
* Add a fully automated test suite, using the GTest framework
* Allow 'null' nodes to return a value without warnings
* Add support for parsing Unicode characters escaped using \uXXXX
* Make the deserialization of G_TYPE_STRV properties more robust
* Export the public symbols only
* Provide GTypes for the enumerations
* Avoid a warning when trying to copy an empty JsonNode
* Fix gtk-doc cross-references with GLib and GObject documentation
Overview of changes for 0.4.0
* Support parsing of negative numbers
* Fix parse error propagation and message
* More parser sanity checks
* GObject deserialization support
* Detect and parse JSON masked as a JavaScript assignment
* Allow using JsonNode with GObject properties and signals
* Add JsonGenerator:root property
JSON-GLib implements a full suite of JSON-related tools using GLib and GObject.
Use JSON-GLib it is possible to parse and generate valid JSON data
structures using a DOM-like API. JSON-GLib also integrates with GObject to
provide the ability to serialize and deserialize GObject instances to and from
JSON data types.
JSON is the JavaScript Object Notation; it can be used to represent objects and
object hierarchies while retaining human-readability.
GLib is a C library providing common and efficient data types for the C
GObject is a library providing a run-time Object Oriented type system for C
developers. GLib and GObject are extensively used by the GTK+ toolkit and by the
[GNOME][gnome] project.
For more information, see:
* [JSON][json]
* [GLib and GObject][glib]
* [JSON-GLib][json-glib]
In order to build JSON-GLib you will need:
* python3
* [ninja](
* [meson](
* pkg-config
* gtk-doc ≥ 1.13 (optional)
* GLib, GIO ≥ 2.38
* GObject-Introspection ≥ 1.38 (optional)
Build and installation
To build JSON-GLib just run:
$ meson _build .
$ ninja -C _build
$ mesontest -C _build
$ sudo ninja -C _build install
See the [Meson documentation]( for more information.
If you find a bug in JSON-GLib, please file an issue on the
[Issues page][gitlab-issues].
Required information:
* the version of JSON-GLib
* if it is a development version, the branch of the git repository
* the JSON data that produced the bug (if any)
* a small, self-contained test case, if none of the test units exhibit the
buggy behaviour
* in case of a segmentation fault, a full stack trace with debugging
symbols obtained through gdb is greatly appreaciated
JSON-GLib is developed mainly inside a GIT repository available at:
You can clone the GIT repository with:
git clone
If you want to contribute functionality or bug fixes to JSON-GLib you should
fork the json-glib repository, work on a separate branch, and then open a
merge request on Gitlab:
Please, try to conform to the coding style used by JSON-GLib, which is the same
used by projects like GLib, [GTK+][gtk-coding-style], and Clutter. Coding style
conformance is a requirement for upstream acceptance.
Make sure you always run the test suite when you are fixing bugs. New features
should come with a test unit. Patches that regress the test suite will be
Release notes
* Prior to JSON-GLib 0.10, a JsonSerializable implementation could
automatically fall back to the default serialization code by simply
returning NULL from an overridden JsonSerializable::serialize-property
virtual function. Since JSON-GLib 0.10 this is not possible any more. A
JsonSerializable is always expected to serialize and deserialize all
properties. JSON-GLib provides public API for the default implementation
in case the serialization code wants to fall back to that.
Copyright and licensing
JSON-GLib has been written by Emmanuele Bassi
JSON-GLib is released under the terms of the GNU Lesser General Public License,
either version 2.1 or (at your option) any later version.
See the file COPYING for details.
Copyright 2007, 2008 OpenedHand Ltd
Copyright 2009, 2010, 2011, 2012 Intel Corp.
Copyright 2013 Emmanuele Bassi
[json]: "JSON"
[glib]: "GTK+"
[json-glib]: "JSON-GLib wiki"
[gnome]: "GNOME"
import sys
import os
import argparse
def write_template(filename, data):
with open(filename, 'w') as f:
def build_template(testdir, testname):
return "[Test]\nType=session\nExec={}\n".format(os.path.join(testdir, testname))
argparser = argparse.ArgumentParser(description='Generate installed-test data.')
argparser.add_argument('--testdir', metavar='dir', required=True, help='Installed test directory')
argparser.add_argument('--testname', metavar='name', required=True, help='Installed test name')
argparser.add_argument('--outfile', metavar='file', required=True, help='Output file')
argparser.add_argument('--outdir', metavar='dir', required=True, help='Output directory')
args = argparser.parse_args()
write_template(os.path.join(args.outdir, args.outfile), build_template(args.testdir, args.testname))
test -n "$srcdir" || srcdir=$(dirname "$0")
test -n "$srcdir" || srcdir=.
cd $srcdir
VERSION=$(git describe --abbrev=0)
rm -f "${NAME}.tar"
rm -f "${NAME}.tar.xz"
echo "Creating git tree archive…"
git archive --prefix="${NAME}/" --format=tar HEAD > ${NAME}.tar
echo "Compressing archive…"
xz -f "${NAME}.tar"
# configure script adapter for Meson
# Based on build-api:
# Copyright 2010, 2011, 2013 Colin Walters <>
# Copyright 2016, 2017 Emmanuele Bassi
# Licensed under the new-BSD license (
# Build API variables:
# Little helper function for reading args from the commandline.
# it automatically handles -a b and -a=b variants, and returns 1 if
# we need to shift $3.
read_arg() {
# $1 = arg name
# $2 = arg value
# $3 = arg parameter
local rematch='^[^=]*=(.*)$'
if [[ $2 =~ $rematch ]]; then
read "$1" <<< "${BASH_REMATCH[1]}"
read "$1" <<< "$3"
# There is no way to shift our callers args, so
# return 1 to indicate they should do it instead.
return 1
sanitycheck() {
# $1 = arg name
# $1 = arg command
# $2 = arg alternates
local cmd=$( which $2 2>/dev/null )
if [ -x "$cmd" ]; then
read "$1" <<< "$cmd"
return 0
test -z $3 || {
for alt in $3; do
cmd=$( which $alt 2>/dev/null )
if [ -x "$cmd" ]; then
read "$1" <<< "$cmd"
return 0
echo -e "\e[1;31mERROR\e[0m: Command '$2' not found"
exit 1
sanitycheck MESON 'meson'
sanitycheck MESONTEST 'mesontest'
sanitycheck NINJA 'ninja' 'ninja-build'
while (($# > 0)); do
case "${1%%=*}" in
--prefix) read_arg prefix "$@" || shift;;
--bindir) read_arg bindir "$@" || shift;;
--sbindir) read_arg sbindir "$@" || shift;;
--libexecdir) read_arg libexecdir "$@" || shift;;
--datarootdir) read_arg datarootdir "$@" || shift;;
--datadir) read_arg datadir "$@" || shift;;
--sysconfdir) read_arg sysconfdir "$@" || shift;;
--libdir) read_arg libdir "$@" || shift;;
--mandir) read_arg mandir "$@" || shift;;
--includedir) read_arg includedir "$@" || shift;;
--enable-gtk-doc) enable_docs='-Ddocs=true';;
--disable-gtk-doc) enable_docs='-Ddocs=false';;
--enable-introspection) enable_introspection='-Dintrospection=true';;
--disable-introspection) enable_introspection='-Dintrospection=false';;
*) echo -e "\e[1;33mINFO\e[0m: Ignoring unknown option '$1'";;
# Defaults
test -z ${prefix} && prefix="/usr/local"
test -z ${bindir} && bindir=${prefix}/bin
test -z ${sbindir} && sbindir=${prefix}/sbin
test -z ${libexecdir} && libexecdir=${prefix}/bin
test -z ${datarootdir} && datarootdir=${prefix}/share
test -z ${datadir} && datadir=${datarootdir}
test -z ${sysconfdir} && sysconfdir=${prefix}/etc
test -z ${libdir} && libdir=${prefix}/lib
test -z ${mandir} && mandir=${prefix}/share/man
test -z ${includedir} && includedir=${prefix}/include
# The source directory is the location of this file
srcdir=$(dirname $0)
# The build directory is the current location
# If we're calling this file from the source directory then
# we automatically create a build directory and ensure that
# both Meson and Ninja invocations are relative to that
# location
if [[ -f "${builddir}/" ]]; then
mkdir -p _build
NINJA_OPT="-C ${builddir}"
# Wrapper Makefile for Ninja
cat > Makefile <<END
# Generated by configure; do not edit
CC="\$(CC)" CXX="\$(CXX)" ${NINJA} ${NINJA_OPT}
echo "Summary:"
echo " meson:....... ${MESON}"
echo " ninja:....... ${NINJA}"
echo " prefix:...... ${prefix}"
echo " bindir:...... ${bindir}"
echo " sbindir:..... ${sbindir}"
echo " libexecdir:.. ${libexecdir}"
echo " datarootdir:. ${datarootdir}"
echo " datadir:..... ${datadir}"
echo " sysconfdir:.. ${sysconfdir}"
echo " libdir:...... ${libdir}"
echo " mandir:...... ${mandir}"
echo " includedir:.. ${includedir}"
echo " additional:.."
echo " - docs: ${enable_docs}"
echo " - introspection: ${enable_introspection}"
exec ${MESON} \
--prefix=${prefix} \
--libdir=${libdir} \
--libexecdir=${libexecdir} \
--datadir=${datadir} \
--sysconfdir=${sysconfdir} \
--bindir=${bindir} \
--includedir=${includedir} \
--mandir=${mandir} \
--default-library shared \
${enable_docs} \
${enable_introspection} \
${builddir} \
# vim: ai ts=8 noet sts=2 ft=sh
<?xml version="1.0"?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED ''">
<!ENTITY % gtkdocentities SYSTEM "xml/gtkdocentities.ent">
<book id="index" xmlns:xi="">
<title>&package_name; Reference Manual</title>
<para>This document is the API reference for for &package_name; &package_version;.</para>
The latest version of this API reference is also available
<ulink role="online-location" url="">online</ulink>.
If you find any issues in this API reference, please report it
using <ulink type="http" url="&package_bugreport;">the online
bug reporting tool</ulink> at
<year>2007, 2008</year>
<holder>OpenedHand LTD</holder>
<year>2009, 2010, 2011</year>
<holder>Intel Corporation</holder>
Permission is granted to copy, distribute and/or modify this
document under the terms of the <citetitle>GNU Free
Documentation License</citetitle>, Version 1.1 or any later
version published by the Free Software Foundation with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover
Texts. You may obtain a copy of the <citetitle>GNU Free
Documentation License</citetitle> from the Free Software
Foundation by visiting <ulink type="http"
url="">their Web site</ulink> or by writing
The Free Software Foundation, Inc.,
<street>59 Temple Place</street> - Suite 330,
<city>Boston</city>, <state>MA</state> <postcode>02111-1307</postcode>,
<part id="json-overview">
<title>JSON-GLib Overview</title>
JSON-GLib is a library aimed at providing an API for efficient parsing
and writing of JSON (JavaScript Object Notation) streams, using GLib's
data types and API.
JSON (JavaScript Object Notation) is a lightweight data-interchange
format. More information on the grammar is <ulink type="http"
url="">available on</ulink>.
<part id="json-base">
<title>JSON-GLib Reference</title>
JSON-GLib provides wrappers around the complex data types defined
by the JSON specification. The fundamental types are handled using
the Generic Value container (GValue) provided by GLib.
JSON complex data types are either arrays (a n-tuple of items)
or objects (a mapping between a string and a value); arrays and
objects can contain multiple values, including other arrays and
<title>Data Types</title>
<xi:include href="xml/json-node.xml"/>
<xi:include href="xml/json-array.xml"/>
<xi:include href="xml/json-object.xml"/>
<part id="json-streams">
<title>Reading and writing</title>
JSON-GLib provides a parser object to read any valid JSON data
stream and build the data object model in memory.
<xi:include href="xml/json-parser.xml"/>
<xi:include href="xml/json-reader.xml"/>
<xi:include href="xml/json-path.xml"/>
<xi:include href="xml/json-generator.xml"/>
<xi:include href="xml/json-builder.xml"/>
<title>General Purpose API</title>
<xi:include href="xml/json-utils.xml"/>
<part id="json-advanced">
<title>JSON-GLib Advanced API</title>
<xi:include href="xml/json-gobject.xml"/>
<xi:include href="xml/json-serializable.xml"/>
<xi:include href="xml/json-gboxed.xml"/>
<xi:include href="xml/json-gvariant.xml"/>
<xi:include href="xml/json-version.xml"/>
<part id="json-tools">
<title>JSON-GLib Additional Reference</title>
<chapter id="tools">
<title>JSON-GLib Tools</title>
<xi:include href="json-glib-format.xml"/>
<xi:include href="json-glib-validate.xml"/>
<title>Object Hierarchy</title>
<xi:include href="xml/tree_index.sgml"/>
<xi:include href="xml/api-index-full.xml"><xi:fallback/></xi:include>
<index role="deprecated">
<title>Index of deprecated symbols</title>
<xi:include href="xml/api-index-deprecated.xml"><xi:fallback/></xi:include>
<index role="0.4">
<title>Index of new symbols in 0.4</title>
<xi:include href="xml/api-index-0.4.xml"><xi:fallback/></xi:include>
<index role="0.6">
<title>Index of new symbols in 0.6</title>
<xi:include href="xml/api-index-0.6.xml"><xi:fallback/></xi:include>
<index role="0.8">
<title>Index of new symbols in 0.8</title>
<xi:include href="xml/api-index-0.8.xml"><xi:fallback/></xi:include>
<index role="0.10">
<title>Index of new symbols in 0.10</title>
<xi:include href="xml/api-index-0.10.xml"><xi:fallback/></xi:include>
<index role="0.12">
<title>Index of new symbols in 0.12</title>
<xi:include href="xml/api-index-0.12.xml"><xi:fallback/></xi:include>
<index role="0.14">
<title>Index of new symbols in 0.14</title>
<xi:include href="xml/api-index-0.14.xml"><xi:fallback/></xi:include>
<index role="0.16">
<title>Index of new symbols in 0.16</title>
<xi:include href="xml/api-index-0.16.xml"><xi:fallback/></xi:include>
<index role="1.0">
<title>Index of new symbols in 1.0</title>
<xi:include href="xml/api-index-1.0.xml"><xi:fallback/></xi:include>
<index role="1.2">
<title>Index of new symbols in 1.2</title>
<xi:include href="xml/api-index-1.2.xml"><xi:fallback/></xi:include>
<index role="1.4">
<title>Index of new symbols in 1.4</title>
<xi:include href="xml/api-index-1.4.xml"><xi:fallback/></xi:include>
<xi:include href="xml/annotation-glossary.xml"><xi:fallback/></xi:include>
<appendix id="license">
This library is free software; you can redistribute it and/or
modify it under the terms of the <citetitle>GNU Library General
Public License</citetitle> as published by the Free Software
Foundation; either version 2 of the License, or (at your option)
any later version.
This library is distributed in the hope that it will be useful,