Skip to content

How to get all the XXXProxy properties of a ViewModel-based class? #288

Open
@ShannonZ

Description

The class derived from rxui.ViewModel is not JSON serializable, and all existing solutions to make a normal class JSON serializable no longer work.
Is there any easy way to make ViewModel derived class serializable?
Or any interface available to retrieve all the XXXProxy properties?

And verse vice:
Is there any easy way to deserialize an instance from json string?

What I want:

from ex4nicegui import rxui
import json

class SystemParameter(rxui.ViewModel):
    SF:float = 42.0
    RFA:float = 100.0
    PW90:float = 10.0
    Gx_offset:int = 0
    
    def serialize(self):
        with open("syspar.json",'w') as f:
            s = json.dumps(self,default=vars)
            f.writelines(s)
    
   def deserialize(self,json_str:str):
        self = deserialize(json_str)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions