'JSON字符串组合包裹
'使用方法:Objson(Itemjson("name","鹿晗")) ==输出==>{"name":"鹿晗"}
' Arjson (ItJson("name", "鹿晗")) ==输出==>["name":"鹿晗"]
' Objson (ItJson("name", "鹿晗",false)) ==输出==>{"name":鹿晗}
'json处理---加双引号
Public Function ItJson(key As String, value As Variant, Optional ByVal istext As Boolean = True) 'ItemJson==》ItJosn,istext如果是字符串加双引号,否则不加
If istext Then
ItJson = """" & key & """:" & """" & value & """"
Else
ItJson = """" & key & """:" & value
End If
End Function
'json规则格式---对象包裹
Public Function Objson(ParamArray items() As Variant)
Dim item As Variant
Dim tempitem As String
For Each item In items
tempitem = tempitem & "," & item
Next
tempitem = Mid(tempitem, 2)
Objson = "{" & tempitem & "}"
End Function
'json规则格式---数组包裹
Public Function Arjson(ParamArray items() As Variant)
Dim item As Variant
Dim tempitem As String
For Each item In items
tempitem = tempitem & "," & item
Next
tempitem = Mid(tempitem, 2)
Arjson = "[" & tempitem & "]"
End Function
Access软件网交流QQ群(群号:198465573) |