omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    JSON - Open Source Project

    Pythonista
    share json
    1
    2
    2071
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Phuket2
      Phuket2 last edited by

      Guys I come across this project today via another forum. Very interesting. @ccc I think you would like this one if you dont all ready know about it. I was able to install the jsoncut package with StaSh(I have only tried that one). I am struggling a little because of my experience, but it looks great. Below is just me starting out trying to understand what it can do. But looks exciting to me, just thought I would share.

      import ui
      import jsoncut
      import requests
      import json
      import os
      
      _url = "http://ergast.com/api/f1/drivers.json"
      _filename = 'f1driver_info.json'
      
      
      def get_drivers_details():
          if os.path.exists(_filename):
              with open(_filename) as infile:
                  print("data from file")
                  return json.load(infile)
          else:
              response = requests.get(_url)
              with open(_filename, 'w') as outfile:
                  json.dump(response.json(), outfile)
              print("data from web")
              return response.json()
      
      
      class MyClass(ui.View):
          def __init__(self, *args, **kwargs):
              super().__init__(*args, **kwargs)
              self.make_view()
      
          def make_view(self):
              pass
      
      
      if __name__ == '__main__':
          j_drivers = get_drivers_details()
          #print(j_drivers)
          #print(dir(jsoncut.inspector))
          print('-------Inspect-------')
          x = jsoncut.inspector.inspect_json(j_drivers)
          for elm in x:
              print(elm)
      
          #print(help(jsoncut.inspector.get_children))
          print('-------Children-------')
          x = jsoncut.inspector.key_crawler(j_drivers)
          for elm in x:
              print(elm)
      
          print('-------TreeWalker-------')
          x = jsoncut.inspector.tree_walker(j_drivers)
          for elm in x:
              print(elm)
      
          f = (0, 0, 300, 400)
          v = MyClass(frame=f)
          v.present(style='sheet', animated=False)
      
      1 Reply Last reply Reply Quote 0
      • Phuket2
        Phuket2 last edited by

        Sorry, should have put thin in General not here

        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors