API Help

Chris Angelico rosuav at gmail.com
Wed Jun 14 19:45:08 EDT 2017


On Thu, Jun 15, 2017 at 8:34 AM, Erik <python at lucidity.plus.com> wrote:
> On 14/06/17 22:30, Chris Angelico wrote:
>>
>> It wouldn't be the repr() of a Python structure, as that wouldn't have
>> all those trailing zeroes.
>
>
> That depends on what class represents those float values. It doesn't have to
> be the built-in float. Same with the double-quotes instead of single-quotes
> on the strings.
>
> I still think it _could_ be the output of a Python repr() or similar
> (something that is expected to be evaluated as a Python expression). I'm not
> saying it *is*, and secretly I agree that it's probably not, but it _could_
> be.

JSON mandates double quotes, even though JS and Python both support
single. Python's built-in float won't repr like that. Add all that
kind of thing together, and you get my original conclusion that this
is JSON. It's also perfectly parseable as various other things, but
it's still most likely to be JSON.

But...

On Thu, Jun 15, 2017 at 9:08 AM, justin walters
<walters.justin01 at gmail.com> wrote:
> I should also specify that the data you have received is malformed.
>
> JSON should always have an object as the top level structure, not an
> array as in your data.

... JSON doesn't actually mandate that. You can use any top-level
type. The string '"hello"' is a valid JSON-decodable value.

ChrisA



More information about the Python-list mailing list