如何解析通过Angular 5中的查询参数传递的JSON

时间:2018-06-23 07:33:25

标签: arrays json angular query-parameters

我有一个JSON格式-

    { route: 'fullbody', 
        workout: [
           [{exercise:'Squat', sets:'3', reps: '8-12'}, {exercise:'Row', sets:'3', reps: '8-12'}, {exercise:'Deadlift', sets:'3', reps: '8-12'}, {exercise:'Plank', sets:'3', reps: '8-12'}],
           [{exercise:'OHP', sets:'3', reps: '8-12'}, {exercise:'Row', sets:'3', reps: '8-12'}, {exercise:'Deadlift', sets:'3', reps: '8-12'}, {exercise:'Plank', sets:'3', reps: '8-12'}]
        ],
        title: 'Full Body Workout', 
        features: ['easy','3 times week','beginner'], 
        image: 'https://c8.alamy.com/comp/EDYW5M/portrait-of-a-bodybuilder-with-muscular-physique-posing-against-black-EDYW5M.jpg'
}

我已将它作为JSON.Stringify之后的查询参数传递给Dynamic Child Route。 (由于默认情况下数组未作为查询参数传递,因此已将其字符串化了)

像这样传递它-

  <a class="btn waves-effect btn-elegant waves-light" [routerLink]="workoutObj.route" [queryParams]="workoutTableParam">Use Routine <i class="fa fa-angle-double-right"></i></a>

但是,在目标路由中检索executableTableParam时,我得到了以下形式的JSON: enter image description here

如何将其解析回原始格式?

0 个答案:

没有答案