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 659339
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:02:00+00:00 2026-05-13T23:02:00+00:00

In writing a django app, I am returning the following json on a jQuery

  • 0

In writing a django app, I am returning the following json on a jQuery ajax call:

{
    "is_owner": "T", 
    "author": "me",
    "overall": "the surfing lifestyle", 
    "score": "1", 
    "meanings": {
        "0": "something", 
        "1": "something else", 
        "3": "yet something else", 
        "23": "something random"
        }, 
    "user vote": "1"
}

In the javascript/jQuery callback function, I can access the is_owner, author, etc. easily enough.

is_owner = json.is_owner;
author = json.author;

But for meanings, the numbers are different depending on what it pulls from the server. On the server side for the meanings part, right now what I’m doing is constructing a dictionary like so:

meanings_dict = {}
meanings = requested_tayke.meanings.all()
for meaning in meanings:
    meanings_dict[meaning.location] = meaning.text

and then returning a json I create like this:

test_json = simplejson.dumps({'is_owner':is_owner, 'overall':overall, 'score':str(score),'user vote':str(user_vote), 'author': author, 'meanings' : meanings_dict })
print test_json

return HttpResponse(test_json)

My question is this: how do I access the ‘meanings’ data from my json in javascript? I need to loop through all of it. Maybe I need to be loading it into json differently. I have full control so of both the server and client side so I’m willing to change either to make it work. Also worth noting: I’m not using Django’s serialize functionality. I couldn’t make it work with my situation.

  • 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-13T23:02:00+00:00Added an answer on May 13, 2026 at 11:02 pm

    it works (roughly) like how a dict works in python: you can iterate over the keys in a json object.

    var meanings = json.meanings;
    for (var key in meanings )
        var value = meanings[key]; 
    

    it might break if you use a naughty library that adds elements to object’s prototype, so for defensive purposes, the established good practice is to write

    for(var key in meanings)
        if (meanings.hasOwnProperty(key))
            var value = meanings[key];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing a simple real-estate listing app in Django. Each property needs to have
I am in the process of writing a Django/Python based app and I want
Writing an app with django, using the psycopg2 engine. It doesn't always seem to
I'm writing a basic Django application. For testing / development purposes I'm trying to
I'm writing a url rewrite in django that when a person goes to http://mysite.com/urlchecker/http://www.google.com
I'm writing an image bank with Django, and I want to add a button
I am writing a fairly simple Django application where users can enter string queries.
I am writing an application where I will be accessing the database from django
I could use some help writing a regular expression. In my Django application, users
I'm writing a bulk insert script using Django's ORM + custom raw SQL. The

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.