poke-devel
[Top][All Lists]
Advanced

[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: Jose E. Marchesi
Subject: Re: master is broken due to latest changes to pk-mi-json
Date: Fri, 26 Nov 2021 16:41:57 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

> 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.

I think that this:

<<<<<<<
{ 10, 20 }
>>>>>>>

and this:

<<<<<<<
{ 10,
  20,
}
>>>>>>>

Denote the same JSON object using different written representations.

I don't think that json_object_to_json_string makes any promise in that
the returned string is identical when the passed JSON objects are
"equal".

By the way, what does that mean, for a JSON object to be "equal" to
another?  Is that equality by structure?

IMO this is way too complicated for little benefit.

I would still just skip() the tests that rely on comparing JSON objects
if the json library doesn't provide a way to compare JSON objects.


> (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]