On Thu, May 23, 2013 at 02:24:02PM +0200, Arne Goedeke wrote:
> If performance does not matter, you could add a pike function to the
> JSON modules called encode_anyway(), which recursively filters the data
> and passes it on to encode. I personally prefer having a somewhat strict
> encoder/decoder, since that also prevents programmer mistakes, which
> could otherwise go unnoticed.

well, the parser would remain strict if you don't use a callback that
breaks that. (assuming we allow the callback to do that)

> The duplicate key problem you mention is not easy to solve. It would
> also make the encoded mappings non-deterministic, since mappings have no
> order.

i don't see how a callback should change anything.
the order in which keys are encoded is determined by the original
mapping. a callback on keys would not influence that order.

one idea is, while encoding the mapping, to take the return value of the
callback, and check it against the original mapping (which we should
still have, even if we are already halfway done encoding). if the
original mapping already has a key that matches the returned string,
then throw an error, otherwise allow the key.

this would prevent duplicates and only throw an error with wierd data
or if the callback returns the same string for any value.

> ps. i would commit a slightly modified version of your patch, unless you
> think we need to solve the mapping problem, too

please go ahead, it's going to take a while until i'll get to continue
working on this and solve the mapping problem. until then the current
solution is already useful.

greetings, martin.
  • Re:... Arne Goedeke
    • ... Martin Bähr
      • ... Arne Goedeke
        • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
          • ... Martin Bähr
            • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
              • ... Arne Goedeke
              • ... Martin Bähr
              • ... Martin Bähr
              • ... Arne Goedeke
              • ... Martin Bähr
              • ... Arne Goedeke
              • ... Martin Bähr
              • ... Arne Goedeke
              • ... Martin Bähr
              • ... Martin Baehr
              • ... Marcus Comstedt (ACROSS) (Hail Ilpalazzo!) @ Pike (-) developers forum
          • ... Martin Bähr
        • ... Martin Bähr

Reply via email to