Re: Structure Fields bis: JSON mapping (#2504)

--------
Mark Nottingham writes:

> SF's data structures are somewhat weird, because of how HTTP
> fields work. It might be useful to suggest (not mandate) a mapping
> to JSON data structures, e.g., in an appendix.

Probably a good idea.

> We talked about what the right mapping should be in the 2022 HTTP 
> Workshop, and this was what we ended up with on the whiteboard:
>
> ~~~
> {
>    "@type": "string",
>    "@val": "foo",
>    "a": 1,
>    "b": 2
> }
> ~~~

I am trying to figure out how the sf-header your example started from.

Are 'a' and 'b' parameters ?

	Bla: "foo";a=1;b=2
	
If so, I would have expected:

    {
        "@type": "string",
        "@val": "foo",
        "a": {
            "@type": "number",
            "@val": 1
        },
        "b": {
            "@type": "number",
            "@val": 2
        }
    }

or maybe ?

    {
        "@type": "string",
        "@val": "foo",
        "@param": {
            "a": {
                "@type": "integer",
                "@val": 1
            },
            "b": {
                "@type": "integer",
                "@val": 2
            }
        }
    }

(In which case we could drop the '@' ?)

I guess sf-binary would look something like ?

    {
        "@type": "binary",
        "@val": "cHJldGVuZCB0aGlzIGlzIGJpbmFyeSBjb250ZW50Lg=="
    }

Working through:

    Example-List: ("foo"; a=1;b=2);lvl=5, ("bar" "baz");lvl=1

I get:

    {
        "@type": "list",
        "@val": [
             {
                 "@type": "inner-list",
                 "@val": [
                     {
                         "@type": "string",
                         "@val": "foo"
                         "@param": {
                              "a": {
                                  "@type": "integer"
                                  "@val": 1
                              },
                              "b": {
                                  "@type": "integer"
                                  "@val": 2
                              },
                         }
                     },
                 ],
                 "@param": {
                      "lvl": {
                          "@type": "integer"
                          "@val": 5
                      }
                 }
             },
             {
                 "@type": "inner-list",
                 "@val": [
                     {
                         "@type": "string",
                         "@val": "bar"
                     },
                     {
                         "@type": "string",
                         "@val": "baz"
                     },
                 ],
                 "@param": {
                      "lvl": {
                          "@type": "integer"
                          "@val": 1
                      }
                 }
             }
        ]
    }


Something like that ?

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.

Received on Friday, 14 April 2023 07:53:15 UTC