我有个json是这样的- "wei_hai_shi_bie":[
- {
- "name":"机械伤害",
- "ancestors":[
- {
- "Id":"D1FE114C-2118-5E91-DA49-3A0B54DB0F94",
- "HierarchyId":"/31/",
- "HierarchyLevel":1,
- "ColorContent":"",
- "ColorSwitch":false,
- "name":"危害识别-南京诚志送电"
- }
- ],
- "id":"fdf53428-6039-b2c3-76d5-3a0b54db5920",
- "dictCode":"D1FE114C-2118-5E91-DA49-3A0B54DB0F94",
- "nodeCode":"ji_xie_shang_hai",
- "colorContent":"",
- "colorSwitch":false,
- "hierarchyId":"/31/1/",
- "TAGSORT":0
- },
- {
- "name":"触电",
- "ancestors":[
- {
- "Id":"D1FE114C-2118-5E91-DA49-3A0B54DB0F94",
- "HierarchyId":"/31/",
- "HierarchyLevel":1,
- "ColorContent":"",
- "ColorSwitch":false,
- "name":"危害识别-南京诚志送电"
- }
- ],
- "id":"0cf5622a-8563-9137-c706-3a0b54db70e6",
- "dictCode":"D1FE114C-2118-5E91-DA49-3A0B54DB0F94",
- "nodeCode":"chu_dian",
- "colorContent":"",
- "colorSwitch":false,
- "hierarchyId":"/31/2/",
- "TAGSORT":0
- }
- ]
复制代码 我要取出,拿$.['wei_hai_shi_bie']- .name。与”机械伤害,触电,电弧灼伤,误送“作比较。如果包含加方框,但是在软件中放入数据,会自动循环$.['wei_hai_shi_bie']
- .name,导致我脚本拿出来的数据是这样的,我想的是两个一行比如。但是我现在出来的是这样的。代码如下
- Function ProcessData(a As String, b As String) As String
- Dim arrA() As String
- arrA = Split(a, ";")
- Dim result As String
- result = ""
- ' 遍历数组B中的每个元素
- Dim i As Integer
- For Each itema As String In arrA
- If itema = b Then
- result = result & itema & "■ "
- Else
- result = result & itema & "□ "
- End If
- Next
- ' 去掉最后一个逗号
- result = Left(result, Len(result))
- ' 返回结果
- ProcessData = result
- End Function
复制代码
|