我一直在使用PowerShell努力獲取API調用的結果Brightpearl作爲一個JSON字符串:Powershel:●解析嵌套的JSON
我想只獲得了部分稱爲結果....
"results":[[1,1,207,4,3,"2014-09-18T14:15:50.000-04:00",4,"#1014",2],[2,1,207,1,3,"2014-09-29T13:20:52.000-04:00",4,"#1015",2],[3,1,207,1,3,"2014-09-29T13:25:39.000-04:00",4,"#1016",2]]}
使用ConvertFrom-JSON($ BpResults.Content),我只得到了外JSON ....
PS C:> convertfrom-json $BPOrders.Content
response reference
-------- ---------
@{metaData=; results=System.Object[]} @{orderTypeNames=; orderPaymentStatusNames=; orderStatusNames...
我想,也許有些其餘的將獲得通過挖掘到System.Object的[]...但無法找出訪問該語法的語法。理想情況下,我想將結果寫入.CSV文件。
任何想法?
"Original": {
"response": {
"metaData": {
"resultsAvailable": 3,
"resultsReturned": 3,
"firstResult": 1,
"lastResult": 3,
"columns": [
{
"name": "orderId",
"sortable": true,
"filterable": true,
"reportDataType": "IDSET",
"required": false
},
{
"name": "orderTypeId",
"sortable": true,
"filterable": true,
"reportDataType": "INTEGER",
"referenceData": [
"orderTypeNames"
],
"required": false
},
{
"name": "contactId",
"sortable": true,
"filterable": true,
"reportDataType": "INTEGER",
"required": false
},
{
"name": "orderStatusId",
"sortable": true,
"filterable": true,
"reportDataType": "INTEGER",
"referenceData": [
"orderStatusNames"
],
"required": false
},
{
"name": "orderStockStatusId",
"sortable": true,
"filterable": true,
"reportDataType": "INTEGER",
"referenceData": [
"orderStockStatusNames"
],
"required": false
},
{
"name": "createdOn",
"sortable": true,
"filterable": true,
"reportDataType": "PERIOD",
"required": false
},
{
"name": "createdById",
"sortable": true,
"filterable": true,
"reportDataType": "INTEGER",
"required": false
},
{
"name": "customerRef",
"sortable": true,
"filterable": true,
"reportDataType": "STRING",
"required": false
},
{
"name": "orderPaymentStatusId",
"sortable": true,
"filterable": true,
"reportDataType": "INTEGER",
"referenceData": [
"orderPaymentStatusNames"
],
"required": false
}
],
"sorting": [
{
"filterable": {
"name": "orderId",
"sortable": true,
"filterable": true,
"reportDataType": "IDSET",
"required": false
},
"direction": "ASC"
}
]
},
"results": [
[
1,
1,
207,
4,
3,
"2014-09-18T14: 15: 50.000-04: 00",
4,
"#1014",
2
],
[
2,
1,
207,
1,
3,
"2014-09-29T13: 20: 52.000-04: 00",
4,
"#1015",
2
],
[
3,
1,
207,
1,
3,
"2014-09-29T13: 25: 39.000-04: 00",
4,
"#1016",
2
]
]
},
"reference": {
"orderTypeNames": {
"1": "SALES_ORDER"
},
"orderPaymentStatusNames": {
"2": "PARTIALLY_PAID"
},
"orderStatusNames": {
"1": "Draft/Quote",
"4": "Invoiced"
},
"orderStockStatusNames": {
"3": "Allfulfilled"
}
}
}
我我的手機上打字所以它會帶我一段時間才能理清選擇對象 – 2014-10-10 16:58:29
感謝確切的論據...會看一看,然後回報。 --- L – user2901305 2014-10-10 17:37:11
嗨.... Jason:根據您的建議,我做了以下操作: PS C:> BPJson = BPOrders.Content | ConvertToJson – user2901305 2014-10-10 18:07:44