我有一个返回import Vue from 'vue'
import Router from 'vue-router'
// ... All your other components
Vue.use(Router)
const router = new Router({
mode: 'history',
routes: [
{
path: '/',
name: 'Dashboard',
component: Dashboard
},
// ... All your other routes
]
})
router.beforeEach((to, from, next) => {
if (from.query.token && !to.query.token) {
if (to.path === from.path) {
// console.log('Identical routes detected')
return // This is a no-no via the documentation, but a bug in routing to identical routes strips query params, and this prevents that
}
next({path: to.path, query: {token: from.query.token}})
}
next()
})
export default router
格式json
的函数。我使用dict
存储到一个对象中,稍后我会在代码中打印它。我得到的回报并不是我所期望的典型json.dumps()
格式。
相关代码段:
json
打印rasa_decoded_output = interpreter.parse(u"{}".format(textobject.body))
rasa_json_formatted_output = json.dumps(rasa_decoded_output)
会导致此(示例):
rasa_json_formatted_output
这里做错了什么?应该调整什么来让json以其典型格式返回,以便我可以解析并提取所需的属性。
另外,如果我只是打印("text": "This is a test", "entities": < >, "intent_ranking": < ("confidence": 0.71653000212560282, "name": "st_testing" ), ("confidence": 0.05410130707298815, "name": "exists_item" ), ("confidence": 0.024777391815713805, "name": "concierge_contact_request" ), ("confidence": 0.020174561099034895, "name": "exists_sauna" ), ("confidence": 0.018203983982849743, "name": "issue_bugs" ), ("confidence": 0.017985724341235722, "name": "exists_driver" ), ("confidence": 0.01687271448223236, "name": "request_power_adapter - custom" ), ("confidence": 0.016857156745106013, "name": "request_newroom" ), ("confidence": 0.015943797930370658, "name": "presto_cost" ), ("confidence": 0.015567442054810358, "name": "exists_spa" ) >, "intent": ("confidence": 0.07653000212560282, "name": "st_testing" ) )
,它会与打印rasa_decoded_output
完全相同,这表明rasa_json_formatted_output
没有任何效果。
在json.dumps()
上使用json.loads()
会导致错误rasa_decoded_output
答案 0 :(得分:0)
问题可能是rasa_decoded_output
可能不是已解码的json对象尚未。您可能需要先使用json.loads,一旦完成,就可以使用json.dumps