我已将 IBM watson 集成到我的 java 应用程序中。当我在输入中输入一个字符串并单击提交时,它将返回一个 json 字符串。
我想从 JSON 输出中检索所有数据的 ID、百分比和采样误差,并将其打印到控制台。我的目标是通过图表等显示这些值,但现在我想将它打印到控制台。
以下显示了来自 IBM 的 JSON 字符串的输出...
{
"id": "*UNKNOWN*",
"processed_lang": "en",
"source": "*UNKNOWN*",
"tree": {
"children": [
{
"children": [
{
"category": "personality",
"children": [
{
"category": "personality",
"children": [
{
"category": "personality",
"id": "Adventurousness",
"name": "Adventurousness",
"percentage": 0.7576333190619886,
"sampling_error": 0.0546254744
},
{
"category": "personality",
"id": "Artistic interests",
"name": "Artistic interests",
"percentage": 0.9961053555258998,
"sampling_error": 0.1107314804
},
{
"category": "personality",
"id": "Emotionality",
"name": "Emotionality",
"percentage": 0.9969135057125771,
"sampling_error": 0.0512783209
},
{
"category": "personality",
"id": "Imagination",
"name": "Imagination",
"percentage": 0.9999959208042641,
"sampling_error": 0.0688620254
},
{
"category": "personality",
"id": "Intellect",
"name": "Intellect",
"percentage": 0.9994099673298837,
"sampling_error": 0.0605583001
},
{
"category": "personality",
"id": "Liberalism",
"name": "Authority-challenging",
"percentage": 0.9994874479675643,
"sampling_error": 0.0885760288
}
],
"id": "Openness",
"name": "Openness",
"percentage": 0.9737349754461915,
"sampling_error": 0.0654457806
},
{
"category": "personality",
"children": [
{
"category": "personality",
"id": "Achievement striving",
"name": "Achievement striving",
"percentage": 0.2084296846463588,
"sampling_error": 0.1049539128
},
{
"category": "personality",
"id": "Cautiousness",
"name": "Cautiousness",
"percentage": 0.0037975029109792446,
"sampling_error": 0.0970637329
},
{
"category": "personality",
"id": "Dutifulness",
"name": "Dutifulness",
"percentage": 0.07881209714217596,
"sampling_error": 0.066306727
},
{
"category": "personality",
"id": "Orderliness",
"name": "Orderliness",
"percentage": 0.0077044305760685106,
"sampling_error": 0.0746778463
},
{
"category": "personality",
"id": "Self-discipline",
"name": "Self-discipline",
"percentage": 1.437985270622555E-4,
"sampling_error": 0.0503025256
},
{
"category": "personality",
"id": "Self-efficacy",
"name": "Self-efficacy",
"percentage": 0.38675464454076475,
"sampling_error": 0.0979909516
}
],
"id": "Conscientiousness",
"name": "Conscientiousness",
"percentage": 0.001042729975404666,
"sampling_error": 0.08176061570000001
},
{
"category": "personality",
"children": [
{
"category": "personality",
"id": "Activity level",
"name": "Activity level",
"percentage": 0.6196452750702242,
"sampling_error": 0.0832737804
},
{
"category": "personality",
"id": "Assertiveness",
"name": "Assertiveness",
"percentage": 0.26375499982159656,
"sampling_error": 0.0886493817
},
{
"category": "personality",
"id": "Cheerfulness",
"name": "Cheerfulness",
"percentage": 0.10404848807697964,
"sampling_error": 0.1113483353
},
{
"category": "personality",
"id": "Excitement-seeking",
"name": "Excitement-seeking",
"percentage": 0.984475526983271,
"sampling_error": 0.0849837878
},
{
"category": "personality",
"id": "Friendliness",
"name": "Outgoing",
"percentage": 0.0997698590364568,
"sampling_error": 0.08007498760000001
},
{
"category": "personality",
"id": "Gregariousness",
"name": "Gregariousness",
"percentage": 0.21721928079554653,
"sampling_error": 0.0614148761
}
],
"id": "Extraversion",
"name": "Extraversion",
"percentage": 0.1191009678887297,
"sampling_error": 0.0612391351
},
{
"category": "personality",
"children": [
{
"category": "personality",
"id": "Altruism",
"name": "Altruism",
"percentage": 0.9663606952317318,
"sampling_error": 0.0755869969
},
{
"category": "personality",
"id": "Cooperation",
"name": "Cooperation",
"percentage": 0.05636998991462855,
"sampling_error": 0.0841720961
},
{
"category": "personality",
"id": "Modesty",
"name": "Modesty",
"percentage": 0.2979258338307789,
"sampling_error": 0.0604476641
},
{
"category": "personality",
"id": "Morality",
"name": "Uncompromising",
"percentage": 0.23809655664417645,
"sampling_error": 0.067167429
},
{
"category": "personality",
"id": "Sympathy",
"name": "Sympathy",
"percentage": 0.9995292854388587,
"sampling_error": 0.1033760304
},
{
"category": "personality",
"id": "Trust",
"name": "Trust",
"percentage": 0.482389923327414,
"sampling_error": 0.0617374794
}
],
"id": "Agreeableness",
"name": "Agreeableness",
"percentage": 0.020744291827208383,
"sampling_error": 0.10207355
},
{
"category": "personality",
"children": [
{
"category": "personality",
"id": "Anger",
"name": "Fiery",
"percentage": 0.8730389482839509,
"sampling_error": 0.0995015107
},
{
"category": "personality",
"id": "Anxiety",
"name": "Prone to worry",
"percentage": 0.9843445923656408,
"sampling_error": 0.0592009988
},
{
"category": "personality",
"id": "Depression",
"name": "Melancholy",
"percentage": 0.9977329242304231,
"sampling_error": 0.0635185366
},
{
"category": "personality",
"id": "Immoderation",
"name": "Immoderation",
"percentage": 0.9844251835860516,
"sampling_error": 0.057216091000000004
},
{
"category": "personality",
"id": "Self-consciousness",
"name": "Self-consciousness",
"percentage": 0.9212364705122658,
"sampling_error": 0.0613118077
},
{
"category": "personality",
"id": "Vulnerability",
"name": "Susceptible to stress",
"percentage": 0.9754505231012063,
"sampling_error": 0.0910170775
}
],
"id": "Neuroticism",
"name": "Emotional range",
"percentage": 0.016735992752090756,
"sampling_error": 0.09667632949999999
}
],
"id": "Conscientiousness_parent",
"name": "Conscientiousness",
"percentage": 0.001042729975404666
}
],
"id": "personality",
"name": "Big 5"
},
{
"children": [
{
"category": "needs",
"children": [
{
"category": "needs",
"id": "Challenge",
"name": "Challenge",
"percentage": 0.03854668759096469,
"sampling_error": 0.08792646900000001
},
{
"category": "needs",
"id": "Closeness",
"name": "Closeness",
"percentage": 0.11501071999168766,
"sampling_error": 0.08673297320000001
},
{
"category": "needs",
"id": "Curiosity",
"name": "Curiosity",
"percentage": 0.7545746706702292,
"sampling_error": 0.12524725080000002
},
{
"category": "needs",
"id": "Excitement",
"name": "Excitement",
"percentage": 0.5258169972550338,
"sampling_error": 0.1145578396
},
{
"category": "needs",
"id": "Harmony",
"name": "Harmony",
"percentage": 0.20932625096475815,
"sampling_error": 0.11486202649999999
},
{
"category": "needs",
"id": "Ideal",
"name": "Ideal",
"percentage": 0.1024721838723201,
"sampling_error": 0.1040952874
},
{
"category": "needs",
"id": "Liberty",
"name": "Liberty",
"percentage": 0.20202017178331372,
"sampling_error": 0.1511666568
},
{
"category": "needs",
"id": "Love",
"name": "Love",
"percentage": 0.3061638103614429,
"sampling_error": 0.1056569794
},
{
"category": "needs",
"id": "Practicality",
"name": "Practicality",
"percentage": 0.27222283787496954,
"sampling_error": 0.0920142043
},
{
"category": "needs",
"id": "Self-expression",
"name": "Self-expression",
"percentage": 0.4639718943621007,
"sampling_error": 0.0854424349
},
{
"category": "needs",
"id": "Stability",
"name": "Stability",
"percentage": 0.003413184470600239,
"sampling_error": 0.1117462741
},
{
"category": "needs",
"id": "Structure",
"name": "Structure",
"percentage": 0.08844897107940608,
"sampling_error": 0.0840415393
}
],
"id": "Stability_parent",
"name": "Stability",
"percentage": 0.003413184470600239
}
],
"id": "needs",
"name": "Needs"
},
{
"children": [
{
"category": "values",
"children": [
{
"category": "values",
"id": "Conservation",
"name": "Conservation",
"percentage": 0.0023789880748844028,
"sampling_error": 0.0714114533
},
{
"category": "values",
"id": "Openness to change",
"name": "Openness to change",
"percentage": 0.9530706270939822,
"sampling_error": 0.0689225
},
{
"category": "values",
"id": "Hedonism",
"name": "Hedonism",
"percentage": 0.4245648852905599,
"sampling_error": 0.14301226290000002
},
{
"category": "values",
"id": "Self-enhancement",
"name": "Self-enhancement",
"percentage": 0.1393112402607365,
"sampling_error": 0.1088382406
},
{
"category": "values",
"id": "Self-transcendence",
"name": "Self-transcendence",
"percentage": 0.916055096052063,
"sampling_error": 0.086876041
}
],
"id": "Conservation_parent",
"name": "Conservation",
"percentage": 0.0023789880748844028
}
],
"id": "values",
"name": "Values"
}
],
"id": "r",
"name": "root"
}, "word_count": 133, "word_count_message": "输入中有 133 个词。我们需要至少 600 个,最好是 1,200 个或更多,以计算具有统计意义的估计值"}