• dan@upvote.au
    link
    fedilink
    arrow-up
    2
    ·
    11 months ago

    PHP causes so many issues because of the fact that it uses the same syntax for both arrays and dictionaries/maps. [] (or array() in older PHP versions) always JSON encodes to [] because there’s no way to tell if it’s supposed to represent an empty array or an empty dictionary.

    • xmunk@sh.itjust.works
      link
      fedilink
      arrow-up
      2
      arrow-down
      1
      ·
      11 months ago

      Eh. It works just fine. I agree JSON encoding is weird but if you use it the recommended way (just use a StdClass object and throw on the fields you need) it works fine. Someone added half assed support for weird PHP arrays that usually works and is generally good enough.

      • dan@upvote.au
        link
        fedilink
        arrow-up
        1
        ·
        11 months ago

        stdClass is for objects. I’m talking about maps. I guess you could use stdClass for maps too, but that feels weird.