我下面有一种格式的JSON数据(源JSON),并试图使用JOLT库将该JSON数据转换为另一种JSON格式(目标JSON)。我尝试了他们的演示网站,但不断得到解析错误。我不知道我错过了什么。有没有人可以告诉我,我需要使用什么转换JSON来实现目标JSON格式?谢谢你,谢谢
源JSON:
{
"id": 6,
"identifier": "fa7242c8-6574-1c49-ju1f-5gad0659ecmt",
"name": "App List",
"structureType": "iteration",
"hasChildren": true,
"children": [
{
"id": 8,
"identifier": "9990bffb-3edf-4d0b-8584-a542f792de91",
"name": "AppNameOne",
"structureType": "iteration",
"hasChildren": true,
"children": [
{
"id": 783,
"identifier": "03283159-9a79-4f21-8ead-55c071448d54",
"name": "AppNameOne_03.14",
"structureType": "iteration",
"hasChildren": false,
"attributes": {
"startDate": "2018-12-01T00:00:00Z",
"finishDate": "2019-02-08T00:00:00Z"
},
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/AppNameOne/AppNameOne_03.14"
},
{
"id": 1029,
"identifier": "cc6b1e3b-a360-4a1e-afd2-629ca30e2cdf",
"name": "AppNameOne_03.15",
"structureType": "iteration",
"hasChildren": false,
"attributes": {
"startDate": "2020-02-01T00:00:00Z",
"finishDate": "2020-04-08T00:00:00Z"
},
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/AppNameOne/AppNameOne_03.15"
}
],
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/AppNameOne"
},
{
"id": 15,
"identifier": "ddde31b8-33bd-4eb0-b531-b7958fc218d6",
"name": "MyAppTwo",
"structureType": "iteration",
"hasChildren": true,
"children": [
{
"id": 1485,
"identifier": "5257534c-1949-4302-b1d1-ed1e36123645",
"name": "MyAppTwo_03.53",
"structureType": "iteration",
"hasChildren": false,
"attributes": {
"startDate": "2023-04-01T00:00:00Z",
"finishDate": "2023-08-01T00:00:00Z"
},
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/MyAppTwo/MyAppTwo_03.53"
},
{
"id": 1506,
"identifier": "eac635b2-0221-471d-a3da-1d15d000186e",
"name": "MyAppTwo_03.54",
"structureType": "iteration",
"hasChildren": false,
"attributes": {
"startDate": "2023-08-01T00:00:00Z",
"finishDate": "2024-11-29T00:00:00Z"
},
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/MyAppTwo/MyAppTwo_03.54"
},
{
"id": 1511,
"identifier": "b1e1a5cc-f6cd-490e-9419-c3cf5e241fa9",
"name": "MyAppTwo_03.52HF",
"structureType": "iteration",
"hasChildren": false,
"attributes": {
"startDate": "2023-07-17T00:00:00Z",
"finishDate": "2024-11-14T00:00:00Z"
},
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/MyAppTwo/MyAppTwo_03.52HF"
}
],
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/MyAppTwo"
},
{
"id": 113,
"identifier": "caf3744b-47b9-4da5-a6d5-8d85d9943e96",
"name": "DBNameCon",
"structureType": "iteration",
"hasChildren": true,
"children": [
{
"id": 114,
"identifier": "ea67184f-f01f-4240-a15f-e3be3d3a00b8",
"name": "Sb15",
"structureType": "iteration",
"hasChildren": false,
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/DBNameCon/Sb15"
},
{
"id": 115,
"identifier": "730a3ea7-2b01-499f-9323-0f9c92058f6d",
"name": "MS",
"structureType": "iteration",
"hasChildren": false,
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/DBNameCon/MS"
}
],
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/DBNameCon"
},
{
"id": 300,
"identifier": "32a5316b-6b9c-4ce1-9aa1-cb647e90ad40",
"name": "Iteration Name",
"structureType": "iteration",
"hasChildren": false,
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/Iteration%20Name"
},
{
"id": 1448,
"identifier": "a0b3871d-810a-4277-851e-52ed864b2915",
"name": "_ParentApp",
"structureType": "iteration",
"hasChildren": true,
"children": [
{
"id": 1449,
"identifier": "3bc8f2fb-0261-49a0-99a7-5631607ab998",
"name": "FeatureModule",
"structureType": "iteration",
"hasChildren": true,
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/_ParentApp/FeatureModule"
}
],
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations/_ParentApp"
}
],
"_links": {
"self": {
"href": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations"
}
},
"url": "http://tfs.orgname.org:8080/tfs/orgname/1s2ldda4-coda-4a0g-bg01-ueg59d97b086/_apis/wit/classificationNodes/Iterations"
}
字符串
目标JSON:
{
"options":[
{
"key":"AppNameOne_03.14",
"value":"AppNameOne_03.14",
"enabled":false
},
{
"key":"AppNameOne_03.15",
"value":"AppNameOne_03.15",
"enabled":false
},
{
"key":"MyAppTwo_03.53",
"value":"MyAppTwo_03.53",
"enabled":false
},
{
"key":"MyAppTwo_03.54",
"value":"MyAppTwo_03.54",
"enabled":true
},
{
"key":"MyAppTwo_03.52HF",
"value":"MyAppTwo_03.52HF",
"enabled":true
},
{
"key":"Sb15",
"value":"Sb15",
"enabled":true
},
{
"key":"MS",
"value":"MS",
"enabled":true
},
{
"key":"FeatureModule",
"value":"FeatureModule",
"enabled":true
}
]
}
型
1条答案
按热度按时间nkhmeac61#
似乎需要在内部
"children"
数组中循环。因此,可以使用以下转换:字符串
其中
"hasChildren"
假定为"enabled"
,因为它是唯一具有布尔值的属性网站http://jolt-demo.appspot.com/上的 * 演示 * 是:
的数据