Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6165001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T22:05:21+00:00 2026-05-23T22:05:21+00:00

I was trying to serialize a Python list but got errors that it’s not

  • 0

I was trying to serialize a Python list but got errors that it’s not serializable. Is there a limitation on serializing a list of Long integers?

>>> ids=p.values_list('id',flat=True)
>>> ids
[335L, 468L, 481L, 542L, 559L, 567L, 609L]
>>> import simplejson as json
>>> str=json.dumps(ids)

Traceback (most recent call last):
   File "<console>", line 1, in <module>
  File "C:\Program Files\Google\google_appengine\lib\simplejson\simplejson\__ini
t__.py", line 265, in dumps
    return _default_encoder.encode(obj)
  File "C:\Program Files\Google\google_appengine\lib\simplejson\simplejson\encod
er.py", line 216, in encode
    chunks = list(chunks)
  File "C:\Program Files\Google\google_appengine\lib\simplejson\simplejson\encod
er.py", line 495, in _iterencode
    o = _default(o)
  File "C:\Program Files\Google\google_appengine\lib\simplejson\simplejson\encod
er.py", line 190, in default
    raise TypeError(repr(o) + " is not JSON serializable")
TypeError: [335L, 468L, 481L, 542L, 559L, 567L, 609L] is not JSON serializable
>>>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T22:05:22+00:00Added an answer on May 23, 2026 at 10:05 pm

    “I am trying to serialize a Python list…”
    This is actually not quite the full story.
    You are trying to serialize a ValuesListQuerySet.

    >>> type(ids)
    <class 'django.db.models.query.ValuesListQuerySet'>
    

    You can either
    1. convert to a Python list as mentioned in the other great answers, or
    2. serialize just the IDs.

    Django has a built-in way to serialize a QuerySet.
    And you only want the IDs so you may use the fields kwarg.

    from django.core import serializers
    data = serializers.serialize('json', YourEntity.objects.all(), fields=('id',))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to serialize a list of python objects with JSON (using simplejson) and
I'm trying to serialize a custom class that needs to use multiple elements of
I am trying to serialize a list of dictionaries to a csv text file
I'm trying to serialize obj using json (Python). I wish to skip json's unknown
I'm quite new to python (I use python 3), and i'm trying to serialize
In C#, I'm trying to serialize ClassA into XML: [Serializable] public ClassA { [XmlElement]
I'm trying to serialize a Type object in the following way: Type myType =
I am trying to serialize an object to a sql compact database. I am
I had an odd problem today when I was trying to serialize an object.
I'm trying to store an xml serialized object in a cookie, but i get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.