# the JSON object must be string, bytes or bytesarray not dict

**URL:** <https://forum.djangoproject.com/t/the-json-object-must-be-string-bytes-or-bytesarray-not-dict/29247>\
**Category:** Using the ORM\
**Created:** [March 19, 2024, 12:52pm UTC](https://forum.djangoproject.com/t/the-json-object-must-be-string-bytes-or-bytesarray-not-dict/29247 "2024-03-19T12:52:13Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sunkumar-dc1430](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/sunkumar-dc1430/32/20014_2.png) [@sunkumar-dc1430](https://forum.djangoproject.com/u/sunkumar-dc1430)\
**Post date:** [March 19, 2024, 12:52pm UTC](https://forum.djangoproject.com/t/the-json-object-must-be-string-bytes-or-bytesarray-not-dict/29247/1 "2024-03-19T12:52:13Z")

</div>

I am getting the mentioned error when am trying to read JSON data from ORM, DB used is Postgres.  
I am trying to access the JSON filed inside the table, the version used is 3.2.16  
I upgraded from 3.0.6 to 3.2.16 and then got this issue.

Please help if any one of you encountered this issue before

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 19, 2024, 1:09pm UTC](https://forum.djangoproject.com/t/the-json-object-must-be-string-bytes-or-bytesarray-not-dict/29247/2 "2024-03-19T13:09:22Z")

</div>

Please provide the code for the view in which this error is occurring, along with the complete traceback of the error.

Note: When posting code (or tracebacks) here, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code (or traceback), then another line of ```. This forces the forum software to keep your code properly formatted.

---

<div class="post-metadata">

**Author:** ![sunkumar-dc1430](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/sunkumar-dc1430/32/20014_2.png) [@sunkumar-dc1430](https://forum.djangoproject.com/u/sunkumar-dc1430)\
**Post date:** [March 19, 2024, 1:22pm UTC](https://forum.djangoproject.com/t/the-json-object-must-be-string-bytes-or-bytesarray-not-dict/29247/3 "2024-03-19T13:22:06Z")

</div>

code

‘’’ queryset = CLASSNAME.objects.filter(record\_type=record\_type)‘’’

---

<div class="post-metadata">

**Author:** ![sunkumar-dc1430](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/sunkumar-dc1430/32/20014_2.png) [@sunkumar-dc1430](https://forum.djangoproject.com/u/sunkumar-dc1430)\
**Post date:** [March 19, 2024, 1:22pm UTC](https://forum.djangoproject.com/t/the-json-object-must-be-string-bytes-or-bytesarray-not-dict/29247/4 "2024-03-19T13:22:42Z")

</div>

`# TypeError at /api/dcr/

the JSON object must be str, bytes or bytearray, not dict

| Request Method: | GET |
| --- | --- |
| Request URL: | url |
| Django Version: | 3.2.16 |
| Exception Type: | TypeError |
| Exception Value: | the JSON object must be str, bytes or bytearray, not dict |
| Exception Location: | /usr/local/lib/python3.8/json/ **init**.py, line 341, in loads |
| Python Executable: | |
| Python Version: | 3.8.5 |
| Python Path: | |
| Server time: | Tue, 19 Mar 2024 13:13:31 +0000 |

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 19, 2024, 2:01pm UTC](https://forum.djangoproject.com/t/the-json-object-must-be-string-bytes-or-bytesarray-not-dict/29247/5 "2024-03-19T14:01:05Z")

</div>

Side notes: The ``` must be the backtick - ` character and not the apostrophe - '. Also, the lines of ``` must be lines by themselves and not part of a line with other text. And, when posting an error message with traceback, we generally need to see the full message from the server - not the summarized message from the browser.

Also, when asked for a view, please post the complete view, without editing or trying to “obfuscate” any references. It’s too easy to make a mistake, which just creates confusion and lengthens the time needed to try and help you solve the issue.

But, from the information we can see for far,

> [@sunkumar-dc1430](#):
>
> ```auto
> queryset = CLASSNAME.objects.filter(record_type=record_type)
> ^^^^^^^^^^^
> 
> ```

The error message is rather clear and explicit here:

> [@sunkumar-dc1430](#):
>
> the JSON object must be str, bytes or bytearray, not dict

I’m guessing value you are supplying for `record_type` is a dict.

(I’m guessing because we do not have complete information available yet.)

Also see the docs at [Making queries | Django documentation | Django](https://docs.djangoproject.com/en/5.0/topics/db/queries/#querying-jsonfield)

---

<div class="post-metadata">

**Author:** ![sunkumar-dc1430](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/sunkumar-dc1430/32/20014_2.png) [@sunkumar-dc1430](https://forum.djangoproject.com/u/sunkumar-dc1430)\
**Post date:** [March 19, 2024, 3:44pm UTC](https://forum.djangoproject.com/t/the-json-object-must-be-string-bytes-or-bytesarray-not-dict/29247/6 "2024-03-19T15:44:37Z")

</div>

no, record\_type is just a string value, there is filed called enrich\_data in that class, so when I filter data or just even try to access ‘’’ queryset = CLASSNAME.objects.all()‘’ it will throw the same error.

I am trying to read all the values in the class and in that one is a JSON value. Hope you got my point.

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [March 19, 2024, 3:50pm UTC](https://forum.djangoproject.com/t/the-json-object-must-be-string-bytes-or-bytesarray-not-dict/29247/7 "2024-03-19T15:50:57Z")

</div>

> [@sunkumar-dc1430](#):
>
> Hope you got my point.

No, I’m sorry I don’t.

Please post the complete view, the model involved, the complete error message with the traceback, _and_ the value of any variable being used that isn’t otherwise specified from the information above.

---

<div class="post-metadata">

**Author:** ![JasurbekSaydullayev](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/jasurbeksaydullayev/32/30518_2.png) [@JasurbekSaydullayev](https://forum.djangoproject.com/u/JasurbekSaydullayev)\
**Post date:** [November 5, 2025, 2:09pm UTC](https://forum.djangoproject.com/t/the-json-object-must-be-string-bytes-or-bytesarray-not-dict/29247/8 "2025-11-05T14:09:37Z")

</div>

Hello did you fix this problem ?
