[英]Not able to Parse JSON from Jenkins properly
I'm trying to parse JSON from Jenkins's API using request 我正在尝试使用请求从Jenkins的API解析JSON
request({method: 'GET', url}, function(error, response, body) {
console.log(body.toString());
var output_json = JSON.parse(body.toString());
console.log(output_json);
}
After I parse the JSON usingJSON.parse(), few values in the tags are lost. 使用JSON.parse()解析JSON之后,标记中的几个值都丢失了。
Console output of text output before parsing JSON 解析JSON之前的文本输出的控制台输出
{
"_class" : "My.FreeProject",
"actions" : [
{
},
{
"_class" : "FreeProject.Property",
"parameterDefinitions" : [
{
"_class" : "org.choice.Parameter",
"defaultParameterValue" : {
"_class" : "Property",
"value" : "master19.7.0"
},
"description" : "",
"name" : "BUILD_TAG",
"type" : "ChoiceParameter"
},
{
"_class" : "Parameter",
"defaultParameterValue" : {
"_class" : "Value",
"value" : ""
},
"description" : "Random Text",
"name" : "MY_TEST",
"type" : "StringParameterDefinition"
},
{
"_class" : "org.myclass",
"defaultParameterValue" : {
"_class" : "org.newclass"
},
"description" : "",
"name" : "TESTING",
"type" : "NodeParameterDefinition"
}
]
},
{
Console output of text output after parsing JSON 解析JSON之后的文本输出的控制台输出
{ _class: 'My.FreeProject',
actions:
[ {},
{ _class: 'FreeProject.Property',
parameterDefinitions: [Object] },
{},
{},
{},
{},
{},
{},
{},
{},
{ _class: 'com.myclass' } ],
So after parsing JSON, I'm losing some of the text values. 因此,在解析JSON之后,我丢失了一些文本值。 Is there a way I could retrieve all the information of the JSON from Jenkins?
有没有办法可以从Jenkins检索JSON的所有信息? Thanks
谢谢
It doesn't look like anything is missing. 看起来没有什么丢失。 The value of
parameterDefinitions
is just collapsed . parameterDefinitions
的值刚刚合拢 。 Either there is a toggle you can click on to expand it, or use console.dir
instead. 您可以单击以展开它,或者使用
console.dir
代替。
Example from the Chrome console. Chrome控制台中的示例。 Note how it shows
[Array[1]]
instead of [[[[]]]]
after parsing the string into an object. 请注意,在将字符串解析为对象后,它如何显示
[Array[1]]
而不是[[[[]]]]
。 However, the values is still four nested arrays. 但是,值仍然是四个嵌套数组。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.