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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:24:16+00:00 2026-06-07T00:24:16+00:00

I have a Django database, in which I have some JSON stored. I wish

  • 0

I have a Django database, in which I have some JSON stored. I wish to extract this JSON, parse it, and then apply filters / queries to it. More specifically I want to have a dynamic webpage which displays the JSON sorted, filtered or grouped by the users preference.

From reading the Django documentation I can only see how to use pre-made filters like starts_with, but not how to pre-process the data. I did see the option for applying a regex, but I don’t think I can implement a full JSON parser by hand. I currently parse the JSON and then search it using python classes, but that seems to defeat the purpose of using a database, particularly because it is limited in the types of query it can handle.

The JSON is coming from some other source, and has no guarantees about it’s fields or structure.

Thanks in advance,

jhoyla

  • 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-07T00:24:17+00:00Added an answer on June 7, 2026 at 12:24 am

    The best answer I have been able to come up with is to add the JSON to the database as tables on the fly to get two strings of results (I do it this way because dictionaries aren’t guaranteed to maintain order.)

    TABLECONFIG = 'data_result' 
    def jsontodb(conn, jsonarray):
        inits = reduce(lambda x, y: x.union(y.keys()), jsonarray, set())
    
    conn.execute("CREATE TABLE " + TABLECONFIG + " (" + 
    str(map(lambda x: x.encode('UTF-8'), inits)).encode('UTF-8').strip('[]')  + ");")
    for i in jsonarray:
            d = map(lambda y: str(map(lambda x: x.encode('UTF-8'), y)).strip('[]'), zip(*i.items()))    
            conn.execute("INSERT INTO " + TABLECONFIG + " (" + d[0] + ") VALUES (" + d[1] + ");")
    conn.commit()
    
    DBCONFIG = '/work/django.sqlite3'
    def pullquery(query):
        p  = loads(oqr.main(
            [str(x) for x in shlex.split(query.encode('UTF-8'))]
        ))
        conn = sqlite3.connect(DBCONFIG)
        jsontodb(conn, p)
        return conn
    

    Giving the result I want, however this only works if the JSON is at most 1 layer deep (although I imagine that this could be fixed it’s pretty hacky already.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some django apps which are versioned by app name. appv1 appv2 The
I have a database tumblelog (using mongoengine) in which I added some data in
I have a django project in which database values need to be updated fairly
I have a django template in which I wish to present a table of
I have a complex django object, which has properties of other class types. This
I have a second database in my Django application, which is filled with static
I have a django view that searches my database for a name that includes
If you've got a database setup in Django, how can you have the TestRunner
hi i am working on a django python application using sqlite3 database. I have
I have django model which consist of parent child relationship filed I want 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.