Skip to content

Commit 3646880

Browse files
authored
Bugfix/json save with wrong format (#873)
* fix,inspector request miss data * fix bug that json data save with wrong format * same bug
1 parent 25d6576 commit 3646880

File tree

3 files changed

+11
-6
lines changed

3 files changed

+11
-6
lines changed

frontend/src/views/datamanager/DataDetailPlainConfig.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default {
130130
save () {
131131
const newData = {}
132132
Object.assign(newData, JSON.parse(this.editorCache.info))
133-
newData['json'] = this.editorCache.json
133+
newData['json'] = JSON.parse(this.editorCache.json)
134134
this.$store.dispatch('saveDataDetail', newData)
135135
},
136136
onJsonPathChange (payload) {

frontend/src/views/datamanager/DataDetailPlainJSON.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ export default {
130130
save () {
131131
const newData = {}
132132
Object.assign(newData, JSON.parse(this.editorCache.info))
133-
newData['json'] = this.editorCache.json
133+
newData['json'] = JSON.parse(this.editorCache.json)
134134
this.$store.dispatch('saveDataDetail', newData)
135135
},
136136
onJsonPathChange (payload) {

lyrebird/mock/dm/__init__.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,10 +1415,15 @@ def activate(self, search_id, **kwargs):
14151415
self.activated_group[search_id] = group_info
14161416
# Apply config
14171417
if config:
1418-
try:
1419-
self.activate_config = json.loads(config)
1420-
except Exception as e:
1421-
logger.error('Failed to parse the config, the config did not take effect!')
1418+
if isinstance(config, str):
1419+
try:
1420+
self.activate_config = json.loads(config)
1421+
except json.JSONDecodeError:
1422+
logger.error('Failed to parse the config, the config did not take effect!')
1423+
elif isinstance(config, dict):
1424+
self.activate_config = config
1425+
else:
1426+
logger.error('Config must be a JSON string or a JSON object!')
14221427
application._cm.add_config(self.activate_config, type='dm', level=-1, apply_now=True)
14231428
# TODO:After activate
14241429
self._check_activated_data_rules_contains_request_data()

0 commit comments

Comments
 (0)