0
다음 JSON을 다른 구조로 변형하고 싶습니다.자바 스크립트로 트리 구조로 재귀 json을 재배치하는 방법?
소스 JSON :
- 값 = 개체가 요구 느릅 나무로 배열 작용에 의해 === "주석"주석으로
- 주석 = 오브젝트 N 태스크 및 N
- 코멘트를 코멘트 여과 끝없는 더 댓글 및 작업
{
"values": [
{
"action": "COMMENTED",
"comment": {
"text": "comment text",
"comments": [
{
"text": "reply text",
"comments": [],
"tasks": []
}
],
"tasks": [
{
"text": "task text",
"state": "RESOLVED"
}
]
}
}
]
}
을 가질 수 있습니다
[대상 JSON : 객체
- 어레이 (들) (! 재귀)
[
{
"text": "comment text",
"children": [
{
"text": "reply text",
"type": "comment"
},
{
"text": "task text",
"state": "RESOLVED"
}
]
}
]
는 "어린이"입니다
시작일 :
data = data.values.filter((e)=>{
return e.action === 'COMMENTED';
}).map((e)=>{
// hmmm recursion needed, how to solve?
});