Daniel P. Berrange wrote:
On Wed, Sep 03, 2014 at 09:07:35PM -0600, Jim Fehlig wrote:
> From: "Daniel P. Berrange" <berrange(a)redhat.com>
>
> Comparing JSON docs using strcmp is simple, but is not flexible
> as it is sensitive to whitespace used in the doc generation.
> When comparing objects it may also be desirable to treat the
> existance of keys in the actual object but not expected object
> as non-fatal. Introduce a virJSONStringCompare function which
> takes two strings representing expected and actual JSON docs
> and then does a DOM comparison. Comparison is controled with
> the ignore_contexts and flags parameters. No comparison is
> done on context paths specified in ignore_contexts. The
> VIR_JSON_COMPARE_IGNORE_EXPECTED_NULL flag can be used to
> ignore actual values that have changed from an expected value
> of null.
>
> Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
> Signed-off-by: Jim Fehlig <jfehlig(a)suse.com>
> ---
> src/libvirt_private.syms | 1 +
> src/util/virjson.c | 242 +++++++++++++++++++++++++++++++++++++++++++++++
> src/util/virjson.h | 16 ++++
> 3 files changed, 259 insertions(+)
>
Looks good, but perhaps we should also add to tests/virjsontest.c
to verify the ignore context support is working as intended
Yes, good idea. I'll include that in V4.
Regards,
Jim