octave-bug-tracker
[Top][All Lists]
Advanced

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

[Octave-bug-tracker] [bug #60688] jsondecode does not handle some arrays


From: Mike Miller
Subject: [Octave-bug-tracker] [bug #60688] jsondecode does not handle some arrays of structs correctly
Date: Fri, 28 May 2021 14:05:29 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36

URL:
  <https://savannah.gnu.org/bugs/?60688>

                 Summary: jsondecode does not handle some arrays of structs
correctly
                 Project: GNU Octave
            Submitted by: mtmiller
            Submitted on: Fri 28 May 2021 11:05:27 AM PDT
                Category: Octave Function
                Severity: 3 - Normal
                Priority: 5 - Normal
              Item Group: Incorrect Result
                  Status: None
             Assigned to: None
         Originator Name: 
        Originator Email: 
             Open/Closed: Open
                 Release: dev
         Discussion Lock: Any
        Operating System: GNU/Linux

    _______________________________________________________

Details:

Some of the test cases that I reported to the jsonstuff package were
overlooked when these functions were added to Octave. The following JSON
strings decode incorrectly or error in Octave:


jsondecode ('[{}]')
ans =

  0x0 struct array containing the fields:


jsondecode ('[[{}]]')
ans =
{
  [1,1] =

    0x0 struct array containing the fields:


}

jsondecode ('[[{"a": 1}]]')
error: octave_base_value::array_value(): wrong type argument 'scalar struct'


These should all decode to a scalar struct.

And these cases are all wrong, they should decode to struct arrays with
dimensions 2×1, 1×2, and 1×1×2, respectively:


>> jsondecode ('[{}, {}]')
ans =

  0x0 struct array containing the fields:


>> jsondecode ('[[{}, {}]]')
ans =
{
  [1,1] =

    0x0 struct array containing the fields:


}

>> jsondecode ('[[[{}, {}]]]')
ans =
{
  [1,1] =
  {
    [1,1] =

      0x0 struct array containing the fields:


  }

}



You can find these test cases in https://github.com/apjanke/octave-jsonstuff.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?60688>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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