Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JsonFileUpdater class #48

Open
bleudev opened this issue Jul 14, 2024 · 0 comments · May be fixed by #57
Open

JsonFileUpdater class #48

bleudev opened this issue Jul 14, 2024 · 0 comments · May be fixed by #57
Assignees
Labels
new class New class new feature New feature
Milestone

Comments

@bleudev
Copy link
Member

bleudev commented Jul 14, 2024

Add JsonFileUpdater class for simplifying worfking with json files.

file.json:

{
'hello': 'world'
}
f = JsonFileUpdater('file.json')
f['hello'] # 'world'
f['hi'] = 12

file.json after this code:

{
'hello': 'world',
'hi': 12
}

Also i suggest add support for with operator (json.loads -> change keys with [] operator -> json.dumps and write):

with f:
    f['hi'] = 12
    f['hello'] = 34.2

Also i suggest add support for custom loads() and dumps() functions and for indent (if custom loads() or dumps() are provided, they must support indent argument).

f = JsonFileUpdater('file.json', loads=ujson.loads, dumps=ujson.dumps)
f2 = JsonFileUpdater('file.json', indent=4)
@bleudev bleudev added new feature New feature new class New class labels Jul 14, 2024
@bleudev bleudev added this to the 0.3 milestone Jul 14, 2024
@bleudev bleudev self-assigned this Jul 14, 2024
@bleudev bleudev added this to Ufpy Jul 14, 2024
@github-project-automation github-project-automation bot moved this to ⚠ To-Do in Ufpy Jul 14, 2024
@bleudev bleudev moved this from ⚠ To-Do to 🏭 In progress in Ufpy Sep 6, 2024
@bleudev bleudev linked a pull request Sep 8, 2024 that will close this issue
3 tasks
@bleudev bleudev linked a pull request Sep 8, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
new class New class new feature New feature
Projects
Status: 🏭 In progress
Development

Successfully merging a pull request may close this issue.

1 participant