Skip to content

Support for encoding and parsing mixed type JSON Arrays #91936

@SanjayyyV

Description

@SanjayyyV

Is your feature request related to a problem? Please describe.

I've been trying to encode and parse top level mixed type JSON arrays.

Here is an example:
[2, "abc", "cde", {"xyz":[1,2,3]}]).

But the JSON implementation in zephyr only supports encoding and parsing arrays of objects or arrays of primitives.

According to RFC 8259 (The JavaScript Object Notation (JSON) Data Interchange Format):

  • There is no requirement that the values in an array be of the same type.
  • Insignificant whitespace is allowed before or after any of the six structural characters (i.e., A JSON Message can start with an array. No need for it to be an object).
  • These are the six structural characters:
    begin-array = ws %x5B ws ; [ left square bracket
    begin-object = ws %x7B ws ; { left curly bracket
    end-array = ws %x5D ws ; ] right square bracket
    end-object = ws %x7D ws ; } right curly bracket
    name-separator = ws %x3A ws ; : colon
    value-separator = ws %x2C ws ; , c

Describe the solution you'd like

  • JSON Arrays must have their own descriptor type (like json_obj_descr).
  • Separate helper macros to describe JSON arrays that doesn't exist inside of an object.
  • Encoding and parsing of heterogeneous JSON arrays.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions