aspJSON错误-加载JSON会引发溢出';Clng&x27+;Can';t迭代多个记录

aspJSON错误-加载JSON会引发溢出';Clng&x27+;Can';t迭代多个记录,json,asp-classic,Json,Asp Classic,我试图循环使用一些基本的JSON,但由于某种原因,我在加载JSON时遇到了一个溢出:“Clng”错误,无法找出原因。非常感谢您的帮助,谢谢 我在这里使用的是1.19版本的代码:(错误发生在脚本的第265行) 以下是JSON:(它是有效的JSON-I测试) 以下是处理代码: Set oJSON = New aspJSON 'Wrap with events to turn it into a collection so we can loop below (i commented

我试图循环使用一些基本的JSON,但由于某种原因,我在加载JSON时遇到了一个溢出:“Clng”错误,无法找出原因。非常感谢您的帮助,谢谢

我在这里使用的是1.19版本的代码:(错误发生在脚本的第265行)

以下是JSON:(它是有效的JSON-I测试)

以下是处理代码:

    Set oJSON = New aspJSON

    '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).
    'From here: https://stackoverflow.com/questions/30782144/looping-through-json-using-aspjson
    strJSON = "{""events"":" & strJSON & "}"

    'Load JSON string
    oJSON.loadJSON(strJSON)
一旦我们加载了JSON,我就无法从每条记录中打印出数据-我得到:

    'Loop through each item in collection
    For Each oEvent In oJSON.data("events")
        'Errors Here: Object required: '[string: "29599"]'
        Set this = oJSON.data("events").item(oEvent)
        Response.Write this.item("id") & ": " & this.item("title") & "<br>"
        
        For Each link In this.item("links")
            Response.Write link & ":" & this.item("links").item(link) & "<br>"
        Next
    Next
***更新***

JSON代码周围缺少[],现在它将通过第一次迭代和所需对象的错误:'oJSON.data(…).Item(…)'第二次点击
设置this=oJSON.data(“事件”).Item(oEvent)
。我清理了上面的代码,这是我在第一次迭代中打印的:

29599: Lucky Voice
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

ERROR: Object required: 'oJSON.data(...).Item(...)'

这就是答案。这个问题与JSON有关,缺少一个括号-啊!希望这能帮助别人

  • CLNG问题已在评论中通过Flakes建议得到解决-谢谢

  • 循环示例-下面是完整的代码

  • strJSON=“{”“id”“:29599”,“title”“:”“Lucky Voice”“”“category_id”“:45”“sub_category_id”“:[],”“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”“摘要:”“幸运之声是地球上最自由、最令人心跳加速、最能肯定生命的私人卡拉OK体验。但不要只相信我们的话……”,“描述”:幸运之声-绝对是最好的!为你和你的朋友租一间我们的卡拉OK厅,体验周围最好的乐趣。无论你是12岁还是92岁,喜欢唱歌,这里都是适合你的地方!此外,你不会被任何人打扰,当然,除非你按下“口渴”键饮料按钮…\r\n\r\n开放时间:\r\n周一-周三下午5:30-凌晨1:00\r\n周六下午5:30-凌晨3:00\r\n周三下午3:00-晚上10:30“组织者名称:”幸运之声“,”标签“:”幸运之声“,”图像url“:”https://s3-eu-west-1.amazonaws.com/evvnt.staging/uploads/event_image/event_image/4626090b-9c8d-484d-92e6-c0331d4af9cd/soho3.jpg"",""图像“”URL:[“”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“],”链接“:{”“网站”:”http://go-staging.evvnt.com/29599-0“预订”:http://go-staging.evvnt.com/29599-1“”和“Facebook”:“http://go-staging.evvnt.com/29599-2“”和“推特”:“http://go-staging.evvnt.com/29599-3“”和“YouTube”:“http://go-staging.evvnt.com/29599-4“}”“艺术家”“:”“,”“关键字”“:”“卡拉OK,幸运之声,soho”“价格”“:{”“平均pp”“:”“22英镑”“}”“工作流状态”“:”“报告完成”“,”容量“:”空“,”地点“:”{”“id”“:16838“,”姓名“:”幸运之声“,”地址“,”波兰街“,”地址“,”城镇“:”伦敦“,”国家“:”GB“,”邮政编码“:”W1F 7NQ“,”纬度“:”51.5146901“,”经度“:-0.136974}”,“联系人“,”:{”“姓名“:”联系人姓名“:”联系人姓名“:”26421“,”电子邮件“:”contact26421@example.com,“电话:”“123456789”“},{”“id”“:46658”“title”“:”“在VirtualNuggets.com上的基础SAS在线培训”“category_id”“:124”“sub_category_id”“:[],”“timestamp”“:”“2016-02-10T05:19:39.666806Z”“开始时间”“:”“2016-02-12T01:00:00+00:00”“结束时间”“:”“2024-08-17T23:00:00+01:00”“门时间”“:空”“最后一次输入时间”“:空”“摘要:”“VirtualNuggets是全球提供在线和企业培训的最佳组织之一。”,“描述”:Base SAS提供了一个专门为数据访问、更改和报告而设计的可扩展、包括在内的软件环境。它包括一种第四代编程语言;用于数据处理、信息存储和恢复、唤起性统计和报告编写的现成程序;以及一种有影响力的宏功能,可减少编程时间g时间和保存方面的难题。\r\n\r\nVirtualNuggets是全球提供在线和企业培训的最佳组织之一。我们在Base SAS上提供实时实用培训,每周都会有新一批培训开始。\r\n\r\n有关Base SAS在线培训的详细信息\r\n\r\n邮件:info@virtualnuggetscom\r\n联系:+1-707 666 8949(美国)\t+91-888 556 0202(印度)\r\n网站URL:http://www.virtualnuggets.com/base-sas.html\r\n记录器:http://basesasonlinetraining.blogspot.com\r\n“组织者名称”:“vasubuddi”,“标签”:“basesas”,“图像url”:https://s3-eu-west-1.amazonaws.com/evvnt.staging/uploads/event_image/event_image/a49c513e-f8ce-4095-b51d-989e7d8e3d75/VirtualNuggets.png“,”图像\u URL:[“https://s3-eu-west-1.amazonaws.com/evvnt.staging/uploads/event_image/event_image/a49c513e-f8ce-4095-b51d-989e7d8e3d75/VirtualNuggets.png“],”链接“:{”“网站”:”http://go-staging.evvnt.com/46658-0“查询”:http://go-staging.evvnt.com/46658-1“}”“艺术家”“:”“,”“关键词”“:”“基地sas,sas,在线培训,虚拟UGGETS”“,”“价格”“:{”“培训”“:”“美元0”“,”“工作流程状态”“:”“报告”“容量”“:空”“地点”“:{”“id”“:26319”“名称”“:”“车站道路”“,”“地址1”“:”“车站道路”“。”地址:“,”城镇:“,”桑德威尔“,”国家“:”英国“,”邮政编码“:”B71 4HJ“,”纬度“:”52.5273431“,”经度“:-1.9883300652359}”,“联系人“:{”姓名“:”联系人姓名43585“,”电子邮件“:”contact43585@example.com“,”电话“:”123456789“}”
    '用“事件”换行以将其转换为集合
    strJSON=“{”事件”“:[“&strJSON&“]}”
    Set oJSON=New aspJSON
    '加载JSON字符串
    loadJSON(strJSON)
    '循环遍历集合中的每条记录
    i=0
    对于oJSON.data中的每个eventrec(“事件”)
    “每个记录的速记访问
    
    [{
        "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"
        }
    }]
    
    29599: Lucky Voice
    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
    
    ERROR: Object required: 'oJSON.data(...).Item(...)'