Skip to content

Feature Request: Load from bytearray #572

@ELind77

Description

@ELind77

If the built-in json is jsut calling decode() under the hood then I can jsut do the same explicitly in my code with ujson and that's fine. But I thought it would be nice if ujson would let me skip that step for large JSON objects that happen to be stored as bytearrays because even decoding (and the string garbage) isn't free when the objects are really big and you have hundreds of thousands of them.

What did you do?

Try to pase a bytearray with ujson.

ujson.loads(bytearray(b'123'))

What did you expect to happen?

Expected same behavior as built-in json module:

>>> json.loads(bytearray(b'123'))
123

What actually happened?

>>> ujson.loads(bytearray(b'123'))
Traceback (most recent call last):
  File "/opt/miniconda3/envs/OptimizedPreprocessing/lib/python3.8/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
TypeError: Expected String or Unicode

What versions are you using?

  • OS: OS X
  • Python: 3.8
  • UltraJSON: 5.5.0

Please include code that reproduces the issue.
See above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions