gerritvankuipers / aspjson

Classic ASP JSON Class Reading/Writing
78 stars 40 forks source link

Overflow: 'Clng' #11

Closed dennisgaudenzi closed 3 years ago

dennisgaudenzi commented 3 years ago

I am trying to loop through some basic JSON and for some reason, I am getting a a Overflow: 'Clng' error when loading the JSON and cannot figure out why.

Here is my code, I am using the EXACT version 1.19 code from here: https://github.com/gerritvankuipers/aspjson

    Set oJSON = New aspJSON
    strJSON = strSJON 'SEE BELOW

    'Wrap with events to turn it into a collection so we can loop below (i commented this out, i get the same error regardless though)
    'strJSON = "{""events"":" & strJSON & "}"

    'Load JSON string
    oJSON.loadJSON(strJSON)

I cannot even get past this point since the error happens above this:

    'Loop through collection
    For Each oEvent In oJSON.data("events")
        Set this = oJSON.data("events").item(oEvent)
        Response.Write this.item("id") & ": " & this.item("title") & "<br>"

        'Get single value
        'Response.Write oJSON.data("firstName") & "<br>"

        'Loop through collection
        For Each link In oJSON.data("links")
             Set this = oJSON.data("links").item(link)
             Response.Write this.item("website") & "<br>"
        Next
    Next

Here is the JSON:

[{"id":29599,"title":"Lucky Voice","category_id":45,"sub_category_ids":[],"timestamp":"2015-07-01T13:06:31.851013Z","start_time":"2015-07-01T17:00:00+01:00","end_time":"2021-07-01T03:00:00+01:00","door_time":null,"last_entry_time":null,"summary":"Lucky Voice is the most liberating, heart-racing, life-affirming private karaoke experience on Earth. But don't just take our word for it...","description":"Lucky Voice - simply the best! Hire out one of our karaoke rooms for you and your friends and experience some of the best fun around. Whether you are 12 or 92 and love singing, then this is the place for you! Plus, you wont be disturbed by anyone, unless of course, you press the \"thirsty\" button for a drink...\r\n\r\nOpening Hours:\r\nMon - Wed 5:30pm - 1:00am\r\nThurs - Sat 5:30pm - 3:00am\r\nSun 3:00pm - 10:30pm","organiser_name":"Lucky Voice","hashtag":"luckyvoice","image_url":"https://s3-eu-west-1.amazonaws.com/evvnt.staging/uploads/event_image/event_image/4626090b-9c8d-484d-92e6-c0331d4af9cd/soho3.jpg","image_urls":["https://s3-eu-west-1.amazonaws.com/evvnt.staging/uploads/event_image/event_image/4626090b-9c8d-484d-92e6-c0331d4af9cd/soho3.jpg","https://s3-eu-west-1.amazonaws.com/evvnt.staging/uploads/event_image/event_image/7199c9d4-cfe2-44e9-9523-a1d9e9a78e0d/Brighton%20Pod2.jpg"],"links":{"Website":"http://go-staging.evvnt.com/29599-0","Booking":"http://go-staging.evvnt.com/29599-1","Facebook":"http://go-staging.evvnt.com/29599-2","Twitter":"http://go-staging.evvnt.com/29599-3","YouTube":"http://go-staging.evvnt.com/29599-4"},"artists":"","keywords":"karaoke, lucky voice, soho","prices":{"Average pp":"GBP 22"},"workflow_state":"report_complete","capacity":null,"venue":{"id":16838,"name":"Lucky Voice","address_1":"52 Poland Street","address_2":"","town":"London","country":"GB","postcode":"W1F 7NQ","latitude":51.5146901,"longitude":-0.136974},"contact":{"name":"Contact Name 26421","email":"contact26421@example.com","tel":"123456789"}},{"id":46658,"title":"Base SAS Online Training at VirtualNuggets.com","category_id":124,"sub_category_ids":[],"timestamp":"2016-02-10T05:19:39.666806Z","start_time":"2016-02-12T01:00:00+00:00","end_time":"2024-08-17T23:00:00+01:00","door_time":null,"last_entry_time":null,"summary":"VirtualNuggets is the one of Best organization providing Online and Corporate Training worldwide.","description":"Base SAS provides a scalable, included software environment specially designed for data access, alteration and reporting. It includes a fourth-generation programming language; ready-to-use programs for data handling, information storage and recovery, evocative statistics and report writing; and an influential macro facility that reduces programming time and preservation headaches.\r\n\r\nVirtualNuggets is the one of Best organization providing Online and Corporate Training worldwide. We offer Real-time practical Oriented Training on Base SAS, New batch starts on every week.\r\n\r\nFor more information on Base SAS Online Training\r\n\r\nEmail\t        :  info@virtualnuggets com\r\nContact       :  +1-707 666 8949(USA)\t  +91-888 556 0202(India)\r\nWeb URL    :  http://www.virtualnuggets.com/base-sas.html\r\nBlogger       : http://basesasonlinetraining.blogspot.com\r\n","organiser_name":"vasubuddi","hashtag":"basesas","image_url":"https://s3-eu-west-1.amazonaws.com/evvnt.staging/uploads/event_image/event_image/a49c513e-f8ce-4095-b51d-989e7d8e3d75/VirtualNuggets.png","image_urls":["https://s3-eu-west-1.amazonaws.com/evvnt.staging/uploads/event_image/event_image/a49c513e-f8ce-4095-b51d-989e7d8e3d75/VirtualNuggets.png"],"links":{"Website":"http://go-staging.evvnt.com/46658-0","Inquiries":"http://go-staging.evvnt.com/46658-1"},"artists":"","keywords":"base sas, sas, online training, virtualnuggets","prices":{"Training":"USD 0"},"workflow_state":"reported_on","capacity":null,"venue":{"id":26319,"name":"station road","address_1":"station road","address_2":"","town":"Sandwell","country":"GB","postcode":"B71 4HJ","latitude":52.5273431,"longitude":-1.9883300652359},"contact":{"name":"Contact Name 43585","email":"contact43585@example.com","tel":"123456789"}}]
nielsAmbacht commented 3 years ago

Hi!

We had the same issue. The solution for us was changing the conversion from long to single (clng to csng ) aspjson.asp on Line 241.

val = CSng(Replace(val, ".", ""))

        Private Function aj_ReadNumericValue(ByVal val)
        If Instr(val, ".") > 0 Then
            numdecimals = Len(val) - Instr(val, ".")
            val = CSng(Replace(val, ".", ""))
            val = val / (10 ^ numdecimals)
            aj_ReadNumericValue = val
        Else
            aj_ReadNumericValue = Clng(val)
        End If
    End Function

Don't know if it will work with yours :)

dennisgaudenzi commented 3 years ago

see here for full resolution and good, full example of use. I think need to check v 1.18 vs 1.19 of the ASPJSON code as well on here.

https://stackoverflow.com/questions/67811790/aspjson-error-loading-json-throws-overflow-clng-cant-iterate-multiple-rec