On Fri, May 11, 2018 at 02:59:04PM +0200, Ján Tomko wrote:
> Yajl has not seen much activity upstream recently.
> Switch to using Jansson >= 2.7.
>
> All the platforms we target on
https://libvirt.org/platforms.html
> have a version >= 2.7 listed on the sites below:
>
https://repology.org/metapackage/jansson/versions
>
https://build.opensuse.org/package/show/devel:libraries:c_c++/libjansson
>
> Implement virJSONValue{From,To}String using Jansson, delete the yajl
> code (and the related virJSONParser structure) and report an error
> if someone explicitly specifies --with-yajl.
>
> Also adjust the test data to account for Jansson's different whitespace
> usage for empty arrays and tune up the specfile to keep 'make rpm'
> working when bisecting.
>
> Signed-off-by: Ján Tomko <jtomko(a)redhat.com>
> ---
> src/util/virjson.c | 211 +++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 211 insertions(+)
>
With this change, it should be possible to build with Jansson 2.5 as
well:
diff --git a/src/util/virjson.c b/src/util/virjson.c
index 2f7d624bb3..0d7d368c8a 100644
--- a/src/util/virjson.c
+++ b/src/util/virjson.c
@@ -2056,8 +2056,7 @@ virJSONValueFromJansson(json_t *json)
break;
case JSON_STRING:
- ret = virJSONValueNewStringLen(json_string_value(json),
- json_string_length(json));
+ ret = virJSONValueNewString(json_string_value(json));
break;
case JSON_INTEGER:
@@ -2070,7 +2069,7 @@ virJSONValueFromJansson(json_t *json)
case JSON_TRUE:
case JSON_FALSE:
- ret = virJSONValueNewBoolean(json_boolean_value(json));
+ ret = virJSONValueNewBoolean(json_is_true(json));
Given how that macro works. I'd rather see following:
case JSON_TRUE:
ret = virJSONValueNewBoolean(true);
break;
case JSON_FALSE:
ret = virJSONValueNewBoolean(false);
break;