1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Loading Class Variables from JSON?

Discussão em 'Python' iniciado por Stack, Setembro 15, 2025.

  1. Stack

    Stack Membro Participativo

    I have a class that I'll be instantiating a lot from lines of JSON. Something like:

    class Something:
    def __init__(self, json):
    #load all self variables from simplejson.loads(json) here
    print self.some_variable_loaded_from_json


    I'd like this to be as efficient as possible because this class is loaded hundreds of times a second. I know I can do a for loop with key/value pairs in the dictionary generated from simplejson, but if there's a way to have simplejson just load directly to class variables without that O(n) overhead, that would be awesome.

    Continue reading...

Compartilhe esta Página