Skip to content

A value of null is not understood #12

Open
@Neradoc

Description

@Neradoc

In json "null" is a valid value for an item in a list or object. json.loads("null") returns None.
Because next_value returns json.loads(value_string) or None (or a Transient subclass), and that value is compared to None, a list like [1,2,null,3,4,5] is wrongly interpreted.
Here is a comparison with json_stream too.

import adafruit_json_stream
import json_stream
import io

def test_null_item(json_stream):
    print("-"*10)
    source = io.BytesIO(b'[1,2,null,3,4]')
    stream = json_stream.load(source)
    for item in stream:
        print("-", item)

test_null_item(adafruit_json_stream)
test_null_item(json_stream)
----------
- 1
- 2
----------
- 1
- 2
- None
- 3
- 4

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy