我有一个深度嵌套的json如下:
[
[
{
"heading": "Account Information",
"columns": 2,
"id": "01B5g000015Z7yeEAC",
"rows": 8,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
{
"editableForUpdate": false,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Rating",
"label": "Account Rating"
}
],
"label": "Rating",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Name",
"label": "Account Name"
}
],
"label": "Account Name",
"lookupIdApiName": "Id",
"sortable": false,
"required": true
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Phone",
"label": "Account Phone"
}
],
"label": "Phone",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "ParentId",
"label": "Parent Account ID"
}
],
"label": "Parent Account",
"lookupIdApiName": "ParentId",
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Fax",
"label": "Account Fax"
}
],
"label": "Fax",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "AccountNumber",
"label": "Account Number"
}
],
"label": "Account Number",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Website",
"label": "Website"
}
],
"label": "Website",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Site",
"label": "Account Site"
}
],
"label": "Account Site",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "TickerSymbol",
"label": "Ticker Symbol"
}
],
"label": "Ticker Symbol",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Type",
"label": "Account Type"
}
],
"label": "Type",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Ownership",
"label": "Ownership"
}
],
"label": "Ownership",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Industry",
"label": "Industry"
}
],
"label": "Industry",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "NumberOfEmployees",
"label": "Employees"
}
],
"label": "Employees",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "AnnualRevenue",
"label": "Annual Revenue"
}
],
"label": "Annual Revenue",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Sic",
"label": "SIC Code"
}
],
"label": "SIC Code",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
}
]
},
{
"heading": "Address Information",
"columns": 2,
"id": "01B5g000015Z7yhEAC",
"rows": 1,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "BillingStreet",
"label": "Billing Street"
},
{
"componentType": "Field",
"apiName": "BillingCity",
"label": "Billing City"
},
{
"componentType": "Field",
"apiName": "BillingState",
"label": "Billing State/Province"
},
{
"componentType": "Field",
"apiName": "BillingPostalCode",
"label": "Billing Zip/Postal Code"
},
{
"componentType": "Field",
"apiName": "BillingCountry",
"label": "Billing Country"
}
],
"label": "Billing Address",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "ShippingStreet",
"label": "Shipping Street"
},
{
"componentType": "Field",
"apiName": "ShippingCity",
"label": "Shipping City"
},
{
"componentType": "Field",
"apiName": "ShippingState",
"label": "Shipping State/Province"
},
{
"componentType": "Field",
"apiName": "ShippingPostalCode",
"label": "Shipping Zip/Postal Code"
},
{
"componentType": "Field",
"apiName": "ShippingCountry",
"label": "Shipping Country"
}
],
"label": "Shipping Address",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
}
]
},
{
"heading": "Additional Information",
"columns": 2,
"id": "01B5g000015Z7yfEAC",
"rows": 4,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "CustomerPriority__c",
"label": "Customer Priority"
}
],
"label": "Customer Priority",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "SLA__c",
"label": "SLA"
}
],
"label": "SLA",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "SLAExpirationDate__c",
"label": "SLA Expiration Date"
}
],
"label": "SLA Expiration Date",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "SLASerialNumber__c",
"label": "SLA Serial Number"
}
],
"label": "SLA Serial Number",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "NumberofLocations__c",
"label": "Number of Locations"
}
],
"label": "Number of Locations",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "UpsellOpportunity__c",
"label": "Upsell Opportunity"
}
],
"label": "Upsell Opportunity",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Active__c",
"label": "Active"
}
],
"label": "Active",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
}
]
},
{
"heading": "System Information",
"columns": 2,
"id": "01B5g000015Z7ygEAC",
"rows": 1,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
]
}
]
},
{
"heading": "Description Information",
"columns": 1,
"id": "01B5g000015Z7yiEAC",
"rows": 1,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Description",
"label": "Account Description"
}
],
"label": "Description",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
}
]
},
{
"heading": "Custom Links",
"columns": 3,
"id": "01B5g000015Z7ydEAC",
"rows": 1,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
]
}
]
}
],
[
{
"heading": "Account Information",
"columns": 2,
"id": "01B5g000015Z7yeEAC",
"rows": 8,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Rating",
"label": "Account Rating"
}
],
"label": "Rating",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Name",
"label": "Account Name"
}
],
"label": "Account Name",
"lookupIdApiName": "Id",
"sortable": false,
"required": true
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Phone",
"label": "Account Phone"
}
],
"label": "Phone",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "ParentId",
"label": "Parent Account ID"
}
],
"label": "Parent Account",
"lookupIdApiName": "ParentId",
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Fax",
"label": "Account Fax"
}
],
"label": "Fax",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "AccountNumber",
"label": "Account Number"
}
],
"label": "Account Number",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Website",
"label": "Website"
}
],
"label": "Website",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Site",
"label": "Account Site"
}
],
"label": "Account Site",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "TickerSymbol",
"label": "Ticker Symbol"
}
],
"label": "Ticker Symbol",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Type",
"label": "Account Type"
}
],
"label": "Type",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Ownership",
"label": "Ownership"
}
],
"label": "Ownership",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Industry",
"label": "Industry"
}
],
"label": "Industry",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "NumberOfEmployees",
"label": "Employees"
}
],
"label": "Employees",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "AnnualRevenue",
"label": "Annual Revenue"
}
],
"label": "Annual Revenue",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Sic",
"label": "SIC Code"
}
],
"label": "SIC Code",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
}
]
},
{
"heading": "Address Information",
"columns": 2,
"id": "01B5g000015Z7yhEAC",
"rows": 1,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "BillingStreet",
"label": "Billing Street"
},
{
"componentType": "Field",
"apiName": "BillingCity",
"label": "Billing City"
},
{
"componentType": "Field",
"apiName": "BillingState",
"label": "Billing State/Province"
},
{
"componentType": "Field",
"apiName": "BillingPostalCode",
"label": "Billing Zip/Postal Code"
},
{
"componentType": "Field",
"apiName": "BillingCountry",
"label": "Billing Country"
}
],
"label": "Billing Address",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "ShippingStreet",
"label": "Shipping Street"
},
{
"componentType": "Field",
"apiName": "ShippingCity",
"label": "Shipping City"
},
{
"componentType": "Field",
"apiName": "ShippingState",
"label": "Shipping State/Province"
},
{
"componentType": "Field",
"apiName": "ShippingPostalCode",
"label": "Shipping Zip/Postal Code"
},
{
"componentType": "Field",
"apiName": "ShippingCountry",
"label": "Shipping Country"
}
],
"label": "Shipping Address",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
}
]
},
{
"heading": "Additional Information",
"columns": 2,
"id": "01B5g000015Z7yfEAC",
"rows": 4,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "CustomerPriority__c",
"label": "Customer Priority"
}
],
"label": "Customer Priority",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "SLA__c",
"label": "SLA"
}
],
"label": "SLA",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "SLAExpirationDate__c",
"label": "SLA Expiration Date"
}
],
"label": "SLA Expiration Date",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "SLASerialNumber__c",
"label": "SLA Serial Number"
}
],
"label": "SLA Serial Number",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "NumberofLocations__c",
"label": "Number of Locations"
}
],
"label": "Number of Locations",
"lookupIdApiName": null,
"sortable": false,
"required": false
},
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "UpsellOpportunity__c",
"label": "Upsell Opportunity"
}
],
"label": "Upsell Opportunity",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
},
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Active__c",
"label": "Active"
}
],
"label": "Active",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
}
]
},
{
"heading": "System Information",
"columns": 2,
"id": "01B5g000015Z7ygEAC",
"rows": 1,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
]
}
]
},
{
"heading": "Description Information",
"columns": 1,
"id": "01B5g000015Z7yiEAC",
"rows": 1,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
{
"editableForUpdate": true,
"editableForNew": true,
"layoutComponents": [
{
"componentType": "Field",
"apiName": "Description",
"label": "Account Description"
}
],
"label": "Description",
"lookupIdApiName": null,
"sortable": false,
"required": false
}
]
}
]
},
{
"heading": "Custom Links",
"columns": 3,
"id": "01B5g000015Z7ydEAC",
"rows": 1,
"collapsible": false,
"useHeading": false,
"layoutRows": [
{
"layoutItems": [
]
}
]
}
]
]
我试过用JSONpath作为$。。layoutRows。[?(@.editableForUpdate==true)]。标签,但它不提供所需的标签值,并提供重复值。
你能帮我写出正确的JSONPATH表达式吗?
试试下面的JSONPath
$..layoutItems[?(@.editableForUpdate == true)].layoutComponents[*].label
Jayway JSONPath(JavaDSL)在线工具:https://jsonpath.herokuapp.com/
问题内容: 假设我有一个像这样的JSON数组: 不,我想基于id查找某个对象,一旦有了该对象,就需要它的子代及其所有childs子代 所以可以说如果 4d024610-a39b-49ce-8581-a18500739a75* 我想找到一个具有ID的元素 * 那应该找到Element Sub2 现在,它应该产生所有将产生的所有子元素id id: 假设我会做 因此,我猜它有两个部分,首先找到“父”元素
问题内容: 假设我有一个对象: 我想找到一个id为1的对象。是否有类似这样的功能?我可以使用Underscore的方法,但必须从顶部开始然后向下过滤。 问题答案: 递归是您的朋友。我更新了该函数以说明属性数组:
问题内容: 我想列出角度为2 * ngFor的以下json的状态和类型。家长属性也应呈现。 角度2: 当然这是行不通的。没有很多数据转换就可以吗?我不确定如何获取json数组的数组。 问题答案: 您需要使用数组。如果要在此级别使用对象,则应考虑使用自定义管道。 基于此,我将以这种方式重构您的代码: 使用以下管道:
我有以下mongodb文档结构: 我已经能够使用$elemMatch来更新操作中的字段,但当我尝试对参数执行相同的操作(修改)时,它似乎不起作用。我想知道,为了能够通过pid查找特定参数中的字段,我应该尝试其他什么方法来成功更新字段。 我目前拥有但不起作用的更新代码如下所示:
我有一个这样的数组: 中的数组包括另外两个数组(第一个不是必需的,但看看第二个(:这个数组包含不同的 x/y 坐标 ) 我想得到另一个数组的结果,如下所示(解释如下): 数组现在按其 x 值排序 ( -- 我不知道如何编码;这是我到目前为止所拥有的: 编辑:有一点忘记说了,就是应该分组的坐标的不应该大于。看下面的例子:
问题内容: PHP数组可以为其元素包含数组。这些数组可以具有数组,依此类推。有没有办法找出PHP数组中存在的最大嵌套?一个示例是一个函数,如果初始数组不具有数组作为元素,则返回1;如果至少一个元素是数组,则返回2,依此类推。 问题答案: 应该这样做: 编辑:非常快速地测试了它,它似乎可以工作。