mirror of
https://e.coding.net/circlecloud/VBFunctionBas.git
synced 2024-12-28 08:08:46 +00:00
db463fa993
Signed-off-by: 502647092 <jtb1@163.com>
32 lines
868 B
QBasic
32 lines
868 B
QBasic
Attribute VB_Name = "JsonUtils"
|
|
Option Explicit
|
|
|
|
Public Function CreateJson(JsonFile As String) As Object
|
|
Dim JsonLine As String
|
|
Dim S As String
|
|
Dim js
|
|
Open JsonFile For Input As 1
|
|
Do Until EOF(1)
|
|
Line Input #1, S
|
|
JsonLine = JsonLine & S
|
|
Loop
|
|
Close #1
|
|
Set js = CreateObject("ScriptControl")
|
|
js.Language = "JScript"
|
|
js.AddCode "function j(s) { return eval('(' + s + ')'); }"
|
|
Set CreateJson = js.Run("j", JsonLine)
|
|
Set js = Nothing
|
|
End Function
|
|
|
|
Public Function StrToJson(ByVal jsonstring As String) As Object
|
|
On Error Resume Next
|
|
Dim S As String
|
|
Dim js
|
|
Set StrToJson = Nothing
|
|
Set js = CreateObject("ScriptControl")
|
|
js.Language = "JScript"
|
|
js.AddCode "function j(s) { return eval('(' + s + ')'); }"
|
|
Set StrToJson = js.Run("j", jsonstring)
|
|
Set js = Nothing
|
|
End Function
|