[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: master is broken due to latest changes to pk-mi-json

From: Mohammad-Reza Nabipoor
Subject: Re: master is broken due to latest changes to pk-mi-json
Date: Fri, 26 Nov 2021 19:05:13 +0330

On Fri, Nov 26, 2021 at 04:14:15PM +0100, Jose E. Marchesi wrote:
> > On Fri, Nov 26, 2021 at 05:35:46PM +0330, Mohammad-Reza Nabipoor wrote:
> >> 
> >> Unfortunately, we don't have access to members of `struct json_object`;
> >> it's an opaque type.
> >> 
> >> I think we should implement the logic using user-visible API.
> >> It's not that complicated.
> I disagree.  JSON objects may be complex, containing other JSON objects,
> and the comparison logic doesn't seem trivial to me at all.
> > Or even better approach:
> >   Convert JSON to string representation (using `json_object_to_json_string`)
> >   and `strcmp` the string representation of objects.
> >
> > I think due to the fact that we just use `json_object_equal` in testsuite,
> > it's totally fine to use this not-so-optimized approach.
> > WDYT?
> This would be feasible, but may lead to spurious results depending on
> how the conversion routine is implemented: there may not be a 1-1
> relationship between the written representation and the JSON object.

The whole purpose of a JSON library is to encode/decode to/from string
representation. If a library fails on this simple thing, we should not use
it at all.
(and also JSON is a simple, linear encoding; it doesn't have any
reference-like construct).

In our MI implmentation, we're relying on the correctness of
JSON<->string conversions (poke sends the string representation, and reads
string representation).

And here we're not talking about a general `json_object_equal`, we're talking
about our testcases. IMHO it's important for us to make sure that
we always get the same string representation.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]