-2
我想从Watson获取JSON对象输出并将其解析为可添加到字符串中的HTML表格,该字符串作为电子邮件发送。 我试过使用几个插件,如json2html,但似乎无法让他们任何工作。从JSON对象呈现HTML表格而不使用jQuery
我的JSON对象看起来是这样的:
WATSON TONE: {
"document_tone": {
"tone_categories": [
{
"tones": [
{
"score": 0.15756,
"tone_id": "anger",
"tone_name": "Anger"
},
{
"score": 0.192775,
"tone_id": "disgust",
"tone_name": "Disgust"
},
{
"score": 0.186713,
"tone_id": "fear",
"tone_name": "Fear"
},
{
"score": 0.255821,
"tone_id": "joy",
"tone_name": "Joy"
},
{
"score": 0.207131,
"tone_id": "sadness",
"tone_name": "Sadness"
}
],
"category_id": "emotion_tone",
"category_name": "Emotion Tone"
},
{
"tones": [
{
"score": 0,
"tone_id": "analytical",
"tone_name": "Analytical"
},
{
"score": 0,
"tone_id": "confident",
"tone_name": "Confident"
},
{
"score": 0,
"tone_id": "tentative",
"tone_name": "Tentative"
}
],
"category_id": "writing_tone",
"category_name": "Writing Tone"
},
{
"tones": [
{
"score": 0.803,
"tone_id": "openness_big5",
"tone_name": "Openness"
},
{
"score": 0.56,
"tone_id": "conscientiousness_big5",
"tone_name": "Conscientiousness"
},
{
"score": 0.149,
"tone_id": "extraversion_big5",
"tone_name": "Extraversion"
},
{
"score": 0.012,
"tone_id": "agreeableness_big5",
"tone_name": "Agreeableness"
},
{
"score": 0.387,
"tone_id": "neuroticism_big5",
"tone_name": "Emotional Range"
}
],
"category_id": "social_tone",
"category_name": "Social Tone"
}
]
}
}
,我想,看起来像这样的字符串中添加它。
emailText = '<html><body><h2>Original Email: </h2><p>' + watsonInput + '</p> <h2>Results: </h2><p>' + jsonOutput + ' </p></body></html>';
我有点失去了这里,并采取一看就那么几款前面的问题,但无法弄清楚基于以前的答案,因为很多人建议使用各种jQuery插件。
任何帮助/建议表示赞赏,感谢
也值得看看我们如何创建http://visualizer.json2html.com这将可视化任何json对象..代码是在github这里https://github.com/moappi/visualizer.json2html –