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

  • SEARCH
  • Home
  • 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 9324031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T04:29:34+00:00 2026-06-19T04:29:34+00:00

>>> raw_post_data = request.raw_post_data >>> print raw_post_data {group:{groupId:2, groupName:GroupName}, members:{1:{firstName:fName,lastName:LName,address:address},1: {firstName:f_Name,lastName:L_Name,address:_address}}} >>> create_request =

  • 0
>>> raw_post_data = request.raw_post_data
>>> print raw_post_data
{"group":{"groupId":"2", "groupName":"GroupName"}, "members":{"1":{"firstName":"fName","lastName":"LName","address":"address"},"1": {"firstName":"f_Name","lastName":"L_Name","address":"_address"}}}
>>> create_request = json.loads(raw_post_data)
>>> print create_request
{u'group': {u'groupName': u'GroupName', u'groupId': u'2'}, u'members': {u'1': {u'lastName': u'L_Name', u'firstName': u'f_Name', u'address': u'_address'}}}

As you can see members with key ‘1’ is overwritten when I use json.dumps()

Is there any way to catch it as exception in python, saying found duplicate keys in request from client ?

  • 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-06-19T04:29:35+00:00Added an answer on June 19, 2026 at 4:29 am

    The rfc 4627 for application/json media type recommends unique keys but it doesn’t forbid them explicitly:

    The names within an object SHOULD be unique.

    From rfc 2119:

    SHOULD This word, or the adjective "RECOMMENDED", mean that there
    may exist valid reasons in particular circumstances to ignore a
    particular item, but the full implications must be understood and
    carefully weighed before choosing a different course.

    import json
    
    def dict_raise_on_duplicates(ordered_pairs):
        """Reject duplicate keys."""
        d = {}
        for k, v in ordered_pairs:
            if k in d:
               raise ValueError("duplicate key: %r" % (k,))
            else:
               d[k] = v
        return d
    
    json.loads(raw_post_data, object_pairs_hook=dict_raise_on_duplicates)
    # -> ValueError: duplicate key: u'1'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The code below ends up printing failure. try: print request.raw_post_data json_data = simplejson.loads(request.raw_post_data) except:
Im using TTURLRequest from the cocoa Three20 development library to form a post request.
I'm looking to make an HTTP post request given the raw data that I
I'm having an issue accessing raw request information from PHP when accessing a script
I am submitting a post request with data type json. I am able to
In PHP, php://input enables to read the raw request body data, which is what
If this was a regular post of a form I could go to Request.Form['somevalue']
I'm trying to build a raw HTTP POST request. I don't want to actually
I'm sending the following json message via POST request: { ID:17, FIRST_NAME:John, LAST_NAME:Doe, TOKEN:8cdde0ef552e305cb44e143d3f8c742fb35caab8f360e7
I am trying to make a POST request in which I am supposed to

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.