diff --git a/apps/assets/models/asset/common.py b/apps/assets/models/asset/common.py index 74df4a358..3a38699e8 100644 --- a/apps/assets/models/asset/common.py +++ b/apps/assets/models/asset/common.py @@ -108,7 +108,7 @@ class Asset(NodesRelationMixin, AbsConnectivity, JMSOrgBaseModel): verbose_name=_("Nodes")) is_active = models.BooleanField(default=True, verbose_name=_('Is active')) labels = models.ManyToManyField('assets.Label', blank=True, related_name='assets', verbose_name=_("Labels")) - info = models.JSONField(verbose_name='Info', default=dict, blank=True) # 资产的一些信息,如 硬件信息 + info = models.JSONField(verbose_name=_('Info'), default=dict, blank=True) # 资产的一些信息,如 硬件信息 objects = AssetManager.from_queryset(AssetQuerySet)() diff --git a/apps/common/drf/parsers/base.py b/apps/common/drf/parsers/base.py index 72bedcc97..7f3d4b055 100644 --- a/apps/common/drf/parsers/base.py +++ b/apps/common/drf/parsers/base.py @@ -91,7 +91,11 @@ class BaseFileParser(BaseParser): (col.startswith('[') and col.endswith(']')) or (col.startswith("{") and col.endswith("}")) ): - col = json.loads(col) + try: + col = json.loads(col) + except json.JSONDecodeError as e: + logger.error('Json load error: ', e) + logger.error('col: ', col) new_row.append(col) return new_row