我需要从 PHP 构建一些 JSON。JSON 的结构并不简单:
{
"new" : {
"checkpoints" :
[
{
"id" : "businessidea",
"name" : "business idea",
"purpose" : "Form a business idea",
"customer" :
{ "questions" :
[
{ "questionid" : "id1", "questiontitle": "Evaluate size of the market, likely growth vectors and estimate addressable size.", "answers" :
[
{"answertext" : "an answer here", "answerlink": "", "answers": [
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"}
]},
{"answertext" : "an answer here", "answerlink": "", "answers": [
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"}
]},
{"answertext" : "an answer here", "answerlink": "", "answers": [
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"}
]}
]
},
{ "questionid" : "id2","questiontitle": "Define the needs of the customers and the value we will deliver to the customers - customer pain and our solution", "answers" :
[
{"answertext" : "an answer here", "answerlink": "", "answers": [
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"}
]},
{"answertext" : "an answer here", "answerlink": "", "answers": [
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"}
]},
{"answertext" : "an answer here", "answerlink": "", "answers": [
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"}
]}
]
},
{ "questionid" : "id3","questiontitle": "Define the competitor landscape" , "answers" :
[
{"answertext" : "an answer here", "answerlink": "", "answers": [
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"}
]},
{"answertext" : "an answer here", "answerlink": "", "answers": [
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"}
]},
{"answertext" : "an answer here", "answerlink": "", "answers": [
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"},
{"answertext": "answer text here", "answerlink": "http://google.com"}
]}
]}
]
},
实现这一目标的最佳方法是什么?我是通过使用大量字符串连接来构建这个 json,还是使用 PHP 内置的 JSON 工具可行?