Skip to content

TypeError: the JSON object must be str, bytes or bytearray, not OrderedDict #115

@noraj

Description

@noraj

I'm using last release 2.2.7.

It seems to be a similar error as in #21 that was fixed in v1.3.5. However, it seems exactly the same issue as in #106

So there is maybe another json.loads that should be changed in json.dumps.

While decoding a token:

Token payload values:
…
[+] prop_a = JSON object:
    [+] aaa = "['stuff_a', 'stuff_b', 'stuff_c', 'stuff_d']"
[+] prop_b = JSON object:
Traceback (most recent call last):
  File "/usr/share/jwt-tool/jwt_tool.py", line 2103, in <module>
    rejigToken(headDict, paylDict, sig)
  File "/usr/share/jwt-tool/jwt_tool.py", line 1299, in rejigToken
    comparestamps, expiredtoken = dissectPayl(paylDict)
                                  ^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/jwt-tool/jwt_tool.py", line 1203, in dissectPayl
    if type(castInput(paylDict[claim][subclaim])) == str:
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/jwt-tool/jwt_tool.py", line 595, in castInput
    jsonInput = json.loads(newInput)
                ^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not OrderedDict

The data:

  
  "prop_a": {
    "aaa": [
      "stuff_a",
      "stuff_b",
      "stuff_c",
      "stuff_d"
    ]
  },
  "prop_b": {
    "bbb": {
      "ccc": [
        "stuff_e",
        "stuff_f",
        "stuff_g"
      ]
    }
  },
  

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions