sciprok / vba-json Goto Github PK
View Code? Open in Web Editor NEWAutomatically exported from code.google.com/p/vba-json
Automatically exported from code.google.com/p/vba-json
Public Function JsonRpcCall(url As String, methName As String, args(),
Optional user As String, Optional pwd As String) As Object
Dim r As Object, cli As MSXML2.XMLHTTP60
Dim pText As String
Static reqId As Integer
reqId = reqId + 1
Set r = CreateObject("Scripting.Dictionary")
r("jsonrpc") = "2.0"
r("method") = methName
r("params") = args
r("id") = reqId
pText = toString(r)
''Set cli = CreateObject("MSXML2.XMLHTTP.6.0")
Set cli = New MSXML2.XMLHTTP60
If Len(user) > 0 Then ' If Not IsMissing(user) Then
cli.Open "POST", url, False, user, pwd
Else
cli.Open "POST", url, False
End If
cli.setRequestHeader "Content-Type", "application/json"
cli.Send pText
If cli.Status <> 200 Then
Err.Raise vbObjectError + INVALID_RPC_CALL + cli.Status, ,
cli.statusText
End If
Set r = parse(cli.responseText)
Set cli = Nothing
If r("id") <> reqId Then Err.Raise vbObjectError + INVALID_RPC_CALL, ,
"Bad Response id"
If r.Exists("error") Or Not r.Exists("result") Then
Err.Raise vbObjectError + INVALID_RPC_CALL, , "Json-Rpc Response
error: " & r("error")("message")
End If
If Not r.Exists("result") Then Err.Raise vbObjectError +
INVALID_RPC_CALL, , "Bad Response, missing result"
Set JsonRpcCall = r("result")
End Function
Original issue reported on code.google.com by [email protected]
on 16 Jun 2009 at 11:48
What steps will reproduce the problem?
1. In the parse_test4 subroutine, change any of the ""test"" elems to ""te:st""
2. Run the subroutine
What is the expected output? What do you see instead?
The expected output should be the normal json output from the test. Instead,
Excel freezes - because it is really good at detecting redundancies so it just
loops them as fast as possible till windows asks if you want to crash the
instance and restart.
What version of the product are you using? On what operating system?
The latest version - with Microsoft Office 2007 running on Windows 7
Please provide any additional information below.
Great parser. It's worked really well so far. I'll fix this bug in my instance,
but I'm not sure if I should add my fix here or not. I'm pretty sure it won't
be elegant :)
Original issue reported on code.google.com by [email protected]
on 2 Jun 2012 at 4:19
I have added to parseNumber():
If InStr(value, ".") Or InStr(value, "e") Or InStr(value, "E") Then
' for PT Local Settings where decimal is ","
If CStr(1.2) = "1,2" Then value = Replace(value, ".", ",",
1, -1, 1)
parseNumber = CDbl(value)
Else
parseNumber = CInt(value)
--
Are you planning adding support for JSON-RPC ? That would be nice.
Original issue reported on code.google.com by [email protected]
on 12 Jun 2009 at 9:53
What steps will reproduce the problem?
1. Set json = lib.parse("{"BigNumber":32769}")
2. an Exception was raise because the CInt Cannot process the Big number
What is the expected output? What do you see instead?
Debug.Assert json.Item("BigNumber") = 32769
What version of the product are you using? On what operating system?
Please provide any additional information below.
'I use CLng to replace CInt
Private Function parseNumber(ByRef str As String, ByRef index As Long)
Dim value As String
Dim char As String
Call skipChar(str, index)
Do While index > 0 And index <= Len(str)
char = Mid(str, index, 1)
If InStr("+-0123456789.eE", char) Then
value = value & char
index = index + 1
Else
If InStr(value, ".") Or InStr(value, "e") Or InStr(value, "E")
Then
parseNumber = CDbl(value)
Else
parseNumber = CLng(value) 'CInt(value)
End If
Exit Function
End If
Loop
End Function
Original issue reported on code.google.com by [email protected]
on 9 May 2010 at 1:34
Many of the issues reported have fixes, but they keep getting re-reported
because all the fixes are in comment attachments.
This is happening because this project seems to have no owner.
If anyone sees this who has the ability to add project members, please contact
me. I volunteer to maintain this.
Original issue reported on code.google.com by [email protected]
on 14 Oct 2014 at 11:30
hi.
i glad for using VB JSON parser.
then, i found loop permanently when a string "key" include a colon.
so i changed "parseKey()" tentatively. as following:
Case ":"
If Not dquote And Not squote Then
index = index + 1
Exit Do
ElseIf dquote And Not squote Then
parseKey = parseKey & Char
index = index + 1
End If
just reported it.
thanks,
yamad
Original issue reported on code.google.com by [email protected]
on 5 Sep 2009 at 6:17
What steps will reproduce the problem?
1. parse any JSON with a key containing a ":" (like in google analytics api
answers)
What is the expected output? What do you see instead?
EXP: normal parsing
GOT: infinity loop
check code beginnning at this case-statement:
https://code.google.com/p/vba-json/issues/attachmentText?id=15&aid=150001000&nam
e=jsonlib.cls&token#276
I added an else clause to solve this:
Case ":"
If Not dquote And Not squote Then
index = index + 1
Exit Do
Else
If InStr(vbCrLf & vbCr & vbLf & vbTab & " ", char) Then
Else
parseKey = parseKey & char
End If
index = index + 1
End If
(didn't test this in depth - just for my case)
Original issue reported on code.google.com by [email protected]
on 30 Sep 2014 at 2:20
What steps will reproduce the problem?
1. ddd
2. dx
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 9 Dec 2014 at 3:06
The code lines
1) in skipchar():
While index > 0 And index <= Len(str) And InStr(vbCr & vbLf & vbTab & " ",
Mid(str, index, 1))
and
2) If InStr(vbCrLf & vbCr & vbLf & vbTab & " ", char) Then
The first vbCrLf &
is redundant as it duplicates vbCr & vbLf
AND char is only one character anyway.
(Thanks for fix to parsenumber btw)
Original issue reported on code.google.com by [email protected]
on 28 Mar 2014 at 2:41
What steps will reproduce the problem?
1. Put this string in a variable:
{"total_rows":36778,"offset":26220,"rows":[
{"id":"6b80c0b76","key":"[email protected]","value":{"entryid":"81151F241C2500","subject
":"test subject","senton":"2009-7-09 22:03:43"}},
{"id":"b10ed9bee","key":"[email protected]","value":{"entryid":A7C3CF74EA95C9F","subject
":"test subject2","senton":"2009-4-21 10:18:26"}}]}
2. Instantiate a jsonlib object: "Dim lib As New jsonlib"
3. Define a new JSON object: "Dim json As Object"
4. Instantiate the JSON object by invoking the jsonlib's "parse" method, the
JSON string is the parameter: "Set json = lib.parse(mystring)"
What is the expected output? What do you see instead?
I would expect to be able to access the elements in the json object; the parse
method returns an error.
What version of the product are you using? On what operating system?
r2 from Feb 14,2009 - OS = Windows XP
Please provide any additional information below.
Parsing JSON strings containing a single record works perfectly, I'm using your
VBA library to read/write/delete data in CouchDB.
Original issue reported on code.google.com by [email protected]
on 18 Oct 2009 at 3:14
What steps will reproduce the problem?
I create an Test Case:
Sub parse_test7()
Dim lib As New JSONLib
Dim json As Object
Set json = lib.parse("{""Path"":""C:\\sample\\sample.jpg""}")
Debug.Assert Err.Number = 0
Debug.Print lib.toString(json)
Set json = Nothing
Set lib = Nothing
End Sub
What is the expected output? What do you see instead?
expected:
{"Path":"C:\sample\sample.jpg"}
instead:
{"Path":"C:samplesample.jpg"}
What version of the product are you using? On what operating system?
Please provide any additional information below.
I manual fix by follow:
@@ -149,7 +147,10 @@
index = index + 1
char = Mid(str, index, 1)
Select Case (char)
- Case """", "\\", "/"
+ Case "\"
+ parseString = parseString & "\"
+ index = index + 1
+ Case """", "/", "'"
parseString = parseString & char
index = index + 1
Case "b"
Original issue reported on code.google.com by [email protected]
on 13 May 2010 at 6:33
What steps will reproduce the problem?
1. use an object key containing a space e.g. "{ ""key with 3 spaces"": 1 }"
2. parse the json
3. key no longer has spaces
What is the expected output? What do you see instead?
JSON object keys should be allowed to have spaces.
What version of the product are you using? On what operating system?
mac 2011 excel
Please provide any additional information below.
Here is an easy test to illustrate the problem:
1. change the parseKey() func to public
2. run the following test:
Public Sub test()
Dim s As String, k As String
Dim j As json
Set j = New json
s = """key with spaces"":{""etc..."""
k = j.parseKey(s, 1)
Debug.Print "value '" & k & "' should have spaces but does not"
End Sub
This is easily fixed by replacing the parseKey() line below:
If InStr(vbCrLf & vbCr & vbLf & vbTab & " ", Char) Then
with
If dquote Or squote Then
parseKey = parseKey & Char
ElseIf InStr(vbCrLf & vbCr & vbLf & vbTab & " ", Char) Then
Original issue reported on code.google.com by [email protected]
on 15 Aug 2014 at 10:31
I found an issue that crashes the parseString function where data delimited
with a single quote and containing encoded single quotes.
It causes a freeze. This can be fixed by adding a single quote to the case
statement:
Select Case (char)
Case """", "\\", "/", "'"
SB.Append char
index = index + 1
Case "b"
Original issue reported on code.google.com by [email protected]
on 25 Mar 2009 at 6:13
What steps will reproduce the problem?
1.
2.
3.
What is the expected output? What do you see instead?
What version of the product are you using? On what operating system?
Please provide any additional information below.
Original issue reported on code.google.com by [email protected]
on 7 Jan 2014 at 8:41
Way wont the parser parse the string below ?
It creates the root ListsState but leaves it empty, no sub objects are created.
{"ListsState":{"MenuLocation":["Kelim","ChecklistTools"],"CurentLoadedChecklist"
:"ToolsConfig","InnerDoc":{"DapiotRegel":{"ClassName":"White","CHLTitle":"דפי
ת
רגל","Fields":{}},"ToolsConfig":{"ClassName":"White","CHLTitle":"משקלים
","Fields":{"ToolsConfigHeliID":"036","ToolsConfigCrewSize":"3","ToolsConfigOper
ativeWgt":"1,500","ToolsConfigNumOf669":"0","ToolsConfigNumOf669Doc":"0","ToolsC
onfigNumOf669Med":"0","ToolsConfigNumOf669Equip":"0","ToolsConfigNumOfSol":"0","
ToolsConfigNumOfPax":"0","ToolsConfigCargo":"0","ToolsConfigCar":"0","ToolsConfi
gFuelExtTanks":"0","ToolsConfigFuelTotal":"0","ToolsConfigCarUnits_Save":"ק\"ג
"}}}}}
Original issue reported on code.google.com by [email protected]
on 23 Aug 2010 at 11:15
If you set "," as the decimal point in Control panel / Regional and Language
settings then CDbl("12.34") will throw an error, but CDbl("12,34") will be
parsed correctly.
Some language uses comma for decimal point by default, so you can make more
globalized parseNumber if you replace this:
parseNumber = CDbl(value)
to this:
parseNumber = CDbl(Replace(value, ".", Mid(CStr(0.1), 2, 1)))
Original issue reported on code.google.com by [email protected]
on 11 Oct 2012 at 12:13
What steps will reproduce the problem?
1. parse "text":"\\","row":"12345678"
2.
3.
What is the expected output? What do you see instead?
Expect text \\
get text \",
What version of the product are you using? On what operating system?
current.Excel 2010. Win 7
Please provide any additional information below.
Fix: double backslash in parseString Cannot match a single char
Change
Case """", "\\", "/"
to
Case """", "\", "/"
Original issue reported on code.google.com by [email protected]
on 14 Oct 2014 at 6:57
Some data seemed to have double the enters in text every time it was saved,
it seems to be because
Case "n"
SB.Append vbNewLine
index = index + 1
should be:
Case "n"
SB.Append vbLf
index = index + 1
in the parseString function.
Original issue reported on code.google.com by [email protected]
on 25 Mar 2009 at 6:34
What steps will reproduce the problem?
1. Try to compile and run in 64-bit excel, for example
What is the expected output? What do you see instead?
Attached screenshot shows the error message.
What version of the product are you using? On what operating system?
64-bit office, 64-bit windows 7
Please provide any additional information below.
The attached cStringBuilder.cls has the proper defines to work with 64-bit
systems. I couldn't figure out how to check it into svn here.
-joe
Original issue reported on code.google.com by [email protected]
on 12 Jan 2011 at 7:37
Attachments:
What steps will reproduce the problem?
1. tried to parse a json string with large numbers in
2.
3.
What is the expected output? What do you see instead?
I get an invisible error return, no object produced
What version of the product are you using? On what operating system?
Please provide any additional information below.
There is a cint() in parse number which needs to be a clng() at the very least
Original issue reported on code.google.com by [email protected]
on 6 Sep 2014 at 3:44
I will be testing with example code in the near future, and I'll keep you
posted on how it works. Thanks!
Original issue reported on code.google.com by [email protected]
on 7 Apr 2010 at 3:54
What steps will reproduce the problem?
1. Create a 2-d array, such as:
Dim arr(0 to 1, 0 to 1) as String
arr(0, 0) = "a"
arr(0, 1) = "b"
arr(1, 0) = "c"
arr(1, 1) = "d"
2. Try to convert to JSON with
Debug.Print lib.toString(arr)
What is the expected output? What do you see instead?
I expect [["a", "b"], ["c", "d"]]
but I get a "Type Mismatch" error. If I change the array type to Variant, I
get the following:
[[,],[,]]
but it returns an error.
What version of the product are you using? On what operating system?
json.xls downloaded on 1/15/2010 from the Google Code Site.
Please provide any additional information below.
Thanks for looking into it!
Original issue reported on code.google.com by [email protected]
on 15 Jan 2010 at 10:59
What steps will reproduce the problem?
no steps, this is a question.
What is the expected output? What do you see instead?
How can i read a parsed JSON string as an array?
Original issue reported on code.google.com by [email protected]
on 19 Mar 2009 at 7:59
What steps will reproduce the problem?
1. Dim theData(1,1,1)
theData(0,0,0)=1
Dim lib As New jsonlib
Dim jsonStr As String
jsonStr = lib.toString(theData)
2.
3.
What is the expected output? What do you see instead?
Should see: [[[1,],[,]],[[,],[,]]]
Actually see: [[[,],[,]],[[,],[,]]]
What version of the product are you using? On what operating system?
R2. Windows 7. Excel 2007.
Please provide any additional information below.
The problem occurs in the multiArray function.
As far as I can gather, VBA doesn't allow you to work with an array with an
unknown number of dimensions (it would need a splat operator).
The following code provides a fudge for up to 10 dimensions (with the unneeded
old code commented out.
Private Function multiArray(aBD, iBC, sPS, ByRef sPT) ' Array BoDy, Integer
BaseCount, String PoSition
Dim iDU, iDL, i ' Integer DimensionUBound, Integer DimensionLBound
On Error Resume Next
iDL = LBound(aBD, iBC)
iDU = UBound(aBD, iBC)
Dim sPB1, sPB2, NoDimensions As Long, DimList() As Long ' String PointBuffer1, String PointBuffer2
If Err.Number = 9 Then
sPB1 = sPT & sPS
NoDimensions = Len(sPB1)
ReDim DimList(1 To NoDimensions)
For i = 1 To Len(sPB1)
'If i <> 1 Then sPB2 = sPB2 & ","
'sPB2 = sPB2 & Mid(sPB1, i, 1)
DimList(i) = CLng(Mid(sPB1, i, 1))
Next
' multiArray = multiArray & toString(Eval("aBD(" & sPB2 & ")"))
' multiArray = multiArray & toString(aBD(sPB2)) 'This was the original
line, replaced by DJM by the code Select statement below.
Select Case NoDimensions
Case 1
multiArray = multiArray & toString(aBD(DimList(1)))
Case 2
multiArray = multiArray & toString(aBD(DimList(1), DimList(2)))
Case 3
multiArray = multiArray & toString(aBD(DimList(1), DimList(2), DimList(3)))
Case 4
multiArray = multiArray & toString(aBD(DimList(1), DimList(2), DimList(3), DimList(4)))
Case 5
multiArray = multiArray & toString(aBD(DimList(1), DimList(2), DimList(3), DimList(4), DimList(5)))
Case 6
multiArray = multiArray & toString(aBD(DimList(1), DimList(2), DimList(3), DimList(4), DimList(5), DimList(6)))
Case 7
multiArray = multiArray & toString(aBD(DimList(1), DimList(2), DimList(3), DimList(4), DimList(5), DimList(6), DimList(7)))
Case 8
multiArray = multiArray & toString(aBD(DimList(1), DimList(2), DimList(3), DimList(4), DimList(5), DimList(6), DimList(7), DimList(8)))
Case 9
multiArray = multiArray & toString(aBD(DimList(1), DimList(2), DimList(3), DimList(4), DimList(5), DimList(6), DimList(7), DimList(8), DimList(9)))
Case 10
multiArray = multiArray & toString(aBD(DimList(1), DimList(2), DimList(3), DimList(4), DimList(5), DimList(6), DimList(7), DimList(8), DimList(9), DimList(10)))
Case Else
'Not much point in doing anything here. The error would just leave it blank.
End Select
Else
sPT = sPT & sPS
multiArray = multiArray & "["
For i = iDL To iDU
multiArray = multiArray & multiArray(aBD, iBC + 1, i, sPT)
If i < iDU Then multiArray = multiArray & ","
Next
multiArray = multiArray & "]"
sPT = Left(sPT, iBC - 2)
End If
Err.Clear
End Function
Original issue reported on code.google.com by [email protected]
on 28 Aug 2012 at 12:14
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.