Re: looking for the right way to work with JSONField - behavior inconsistent between strings and integers

2018-05-07 Thread Oliver Zhou
Thanks for the clarification -> although it seems like it should actually raise a warning or exception to prevent non-deterministic data errors when people aren't aware. Oliver On Tuesday, April 24, 2018 at 8:20:53 PM UTC-7, Simon Charette wrote: > > Hello Olivier, > > Since JSON objects can

Re: looking for the right way to work with JSONField - behavior inconsistent between strings and integers

2018-04-24 Thread Simon Charette
Hello Olivier, Since JSON objects can only have string keys[0] I'd suggest you always use strings as dict keys on the Python side to avoid having to deal with both cases. Another solution would to subclass JSONField to override the from_db_value method to turn keys into integer when retrieved

looking for the right way to work with JSONField - behavior inconsistent between strings and integers

2018-04-24 Thread Oliver Zhou
Using Django 1.11, Python 2.7, PostGres, and JSONField I'm getting behavior I don't expect. It seems when JSONField values are initially saved/accessed in memory, they're python "integers", but when saved to the database and then re-accessed, the values are now in string format. *What about