GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — set object is not JSON serializable with iterable_mode=IM_ANY_ITERABLE · Issue #168 · python-rapidjson/python-rapidjson

set object is not JSON serializable with iterable_mode=IM_ANY_ITERABLE #168

New issue
Copy link
New issue
Copy link
Open
#246
Open
set object is not JSON serializable with iterable_mode=IM_ANY_ITERABLE#168
#246
Copy link

Description

@gdub
gdub
opened on Aug 22, 2022
Issue body actions
>>> rapidjson.dumps({1}, iterable_mode=rapidjson.IM_ANY_ITERABLE)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: {1} is not JSON serializable
>>> rapidjson.__version__
'1.8'

Given that documentation states "any iterable will be dumped as a JSON array," I would expect a set object to serialize to an array.

Note, it does appear that creating an iterator object from the set will successfully serialize:

>>> rapidjson.dumps(iter({1}), iterable_mode=rapidjson.IM_ANY_ITERABLE)
'[1]'
Reacted by Aziz Khoury and janw

Activity

  1. lelit commented on Aug 23, 2022

    @lelit
    lelit
    on Aug 23, 2022
    Contributor
    More actions

    Thank you for the report, I will try to understand and fix the issue.

  2. lelit commented on Aug 23, 2022

    @lelit
    lelit
    on Aug 23, 2022
    Contributor
    More actions

    I'm not sure if/how this should be fixed...
    On one hand, I realize that IM_ANY_ITERABLE (that by the way is the default for iterable_mode) suggests that it should slurp anything for which iter(X) works, but under the hood it is actually implemented as PyIter_Check(), and thus it is currently misleading.
    On the other hand, I'm reluctant to effectively rectify its implementation, because that could break existing usages: doing that for example breaks three tests, this to mention one.
    I will think about this, or wait for some feedback 😜

  3. akhoury commented on Nov 8, 2022

    @akhoury
    akhoury
    on Nov 8, 2022
    More actions

    running into this issue as well

  4. lelit commented on Nov 8, 2022

    @lelit
    lelit
    on Nov 8, 2022
    Contributor
    More actions

    I started hacking on this, but got distracted away, sorry. I will try to refocus, as time permits.

    Reacted by Aziz Khoury and Anna Pekarska
  5. NothisIm commented on May 5, 2023

    @NothisIm
    NothisIm
    on May 5, 2023
    More actions

    hi @lelit
    any updates on this? would be really cool to get this fixed 🙏

  6. lelit commented on May 5, 2023

    @lelit
    lelit
    on May 5, 2023
    Contributor
    More actions

    No, sorry 🤦‍♂️

  7. lelit commented on Oct 16, 2026

    @lelit
    lelit
    on Oct 16, 2026
    Contributor
    More actions

    First of all, I'm sorry this is taking so long.

    I reviewed PR #246, and I'm still unsure whether that is the right move here. I'm flip/flopping between two point of views...

    1. IM_ANY_ITERABLE is too broad: should be deprecated and replaced by IM_ANY_ITERATOR, what it really means now
    2. Ok, «practicality beats purity», and sets are a rather common and important iterable to be merit a special treatment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.