• Problem in JSONReader: SET required on class instance assignment

    By Milos Lapis 2 decades ago

    Hello. It is nice to see the tools for parsing JSON in LS. It is really very useful and we are prepared to cooperate in a development cycle. I tried to read some JSON structures by JSONReader but I received the folloving error: SET required on class instance assignment.



    The JSON structure is more complex then just simple examples but I think that the syntax is correct.



    The example of JSON:



    {"commissionid":"171505","InvoiceClient":"V","InvoiceGroup":"101","InvoiceCurr":"CZK","SalesOrder":"1108003503","Status":"F","OBStatus":[{"docid":"78RKJK3685","invoicestatus":"A","invoicedate":"2008-01-31 10:26:57","invoicenote":""},{"docid":"78RKTF2401","invoicestatus":"A","invoicedate":"2008-01-31 10:26:57","invoicenote":""},{"docid":"78RKUA8498","invoicestatus":"A","invoicedate":"2008-01-31 10:26:57","invoicenote":""},{"docid":"78RKVV6996","invoicestatus":"A","invoicedate":"2008-01-31 10:26:57","invoicenote":""},{"docid":"78RKWM3894","invoicestatus":"A","invoicedate":"2008-01-31 10:26:57","invoicenote":""}],"InvList":[{"vbeln":"1108003503","invoice":"4108001920","fkart":"ZF2","fkart_popis":"Faktura","erdat":"2008-01-31 10:26:51","fkdat":"2008-01-31","duedat":"2008-02-14","bezdph":"6 550,00","betr":"7 794,50","waers":"CZK","storno":"","kunnr":"0159025000"},{"vbeln":"1108003503","invoice":"9107002620","fkart":"ZFAZ","fkart_popis":"Požadavek na zálohu","erdat":"2008-01-17 15:01:56","fkdat":"2007-12-31","duedat":"2008-01-14","bezdph":"6 550,00","betr":"7 794,50","waers":"CZK","storno":"","kunnr":"0159025000"}],"ErrorCode":0,"ErrorMessage":""}

    • Not a bug...

      By Troy Reimer 2 decades ago

      I can't reproduce the error. I think that it is probably occurring in how you are assigning the JSONReader.Parse function return to a variable. It always returns an object so it requires a Set statement. Here is how it should be (this works for me):



      Dim sInput As String

      Dim jsonReader As JSONReader

      Dim vResult As Variant 'or Dim vResult as JSONObject



      sInput = |{"commissionid":"171505","InvoiceClient":"V","InvoiceGroup":"101","InvoiceCurr":"CZK","SalesOrder":"1108003503",| &

      |"Status":"F","OBStatus":[{"docid":"78RKJK3685","invoicestatus":"A","invoicedate":"2008-01-31 10:26:57","invoicenote":""},| &


      |{"docid":"78RKTF2401","invoicestatus":"A","invoicedate":"2008-01-31 10:26:57","invoicenote":""},{"docid":"78RKUA8498",| &

      |"invoicestatus":"A","invoicedate":"2008-01-31 10:26:57","invoicenote":""},{"docid":"78RKVV6996","invoicestatus":"A",| &


      |"invoicedate":"2008-01-31 10:26:57","invoicenote":""},{"docid":"78RKWM3894","invoicestatus":"A","invoicedate":| &

      |"2008-01-31 10:26:57","invoicenote":""}],"InvList":[{"vbeln":"1108003503","invoice":"4108001920","fkart":"ZF2",| &


      |"fkart_popis":"Faktura","erdat":"2008-01-31 10:26:51","fkdat":"2008-01-31","duedat":"2008-02-14","bezdph":"6 550,00",| &

      |"betr":"7 794,50","waers":"CZK","storno":"","kunnr":"0159025000"},{"vbeln":"1108003503","invoice":"9107002620",| &


      |"fkart":"ZFAZ","fkart_popis":"Požadavek na zálohu","erdat":"2008-01-17 15:01:56","fkdat":"2007-12-31",| &

      |"duedat":"2008-01-14","bezdph":"6 550,00","betr":"7 794,50","waers":"CZK","storno":"","kunnr":"0159025000"}],| &


      |"ErrorCode":0,"ErrorMessage":""}|



      Set jsonReader = New JSONReader

      Set vResult = jsonReader.Parse(sInput)

      • I apologize, you are right, the problem was on my side ...

        By Milos Lapis 2 decades ago

        Thank you for your reply, I will try to use the library in much more complex applications …