fix(docref): json serialization (#28182)

This commit is contained in:
David Arnold 2024-10-19 16:11:51 +02:00 committed by GitHub
parent 8b1180ba27
commit 75b58802ad
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 6 additions and 3 deletions

View file

@ -5,19 +5,18 @@ fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
rev: v5.0.0
hooks:
- id: trailing-whitespace
files: "frappe.*"
exclude: ".*json$|.*txt$|.*csv|.*md|.*svg"
- id: check-yaml
- id: no-commit-to-branch
args: ['--branch', 'develop']
- id: check-merge-conflict
- id: check-ast
- id: check-json
- id: check-toml
- id: check-yaml
# - id: check-yaml
- id: debug-statements
exclude: ^frappe/tests/classes/context_managers\.py$

View file

@ -221,6 +221,10 @@ def json_handler(obj):
elif isinstance(obj, frappe.model.document.BaseDocument):
return obj.as_dict(no_nulls=True)
elif isinstance(obj, frappe.model.document.DocRef): # if not BaseDocument, but DocRef
return str(obj)
elif isinstance(obj, Iterable):
return list(obj)