aspJSON 错误 - 加载 JSON 引发溢出“Clng”+ 无法迭代多条记录

如何解决aspJSON 错误 - 加载 JSON 引发溢出“Clng”+ 无法迭代多条记录

我正在尝试遍历一些基本的 JSON,但出于某种原因,我在加载 JSON 时收到了一个溢出:'Clng' 错误并且无法弄清楚原因。任何帮助将不胜感激,谢谢。

我正在使用这里的 EXACT 1.19 版代码:https://github.com/gerritvankuipers/aspjson/blob/master/aspJSON1.19.asp(错误发生在脚本的第 265 行)

这是 JSON:(它是有效的 JSON - 我在 https://jsonlint.com/ 上测试过)

strJSON  = "[{""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,""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"",""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""},""keywords"":""base sas,sas,online training,virtualnuggets"",""prices"":{""Training"":""USD 0""},""workflow_state"":""reported_on"",""venue"":{""id"":26319,""name"":""station road"",""address_1"":""station road"",""town"":""Sandwell"",""postcode"":""B71 4HJ"",""latitude"":52.5273431,""longitude"":-1.9883300652359},""contact"":{""name"":""Contact Name 43585"",""email"":""contact43585@example.com"",""tel"":""123456789""}}]"

这是处理代码:

    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

我需要做的是打印/访问每个 ID(29599 和 46658)及其下的所有数据。这里有两条记录,但可能返回 1000 条。

这是格式化的有效 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,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,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,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,"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","summary": "VirtualNuggets is the one of Best organization providing Online and Corporate Training worldwide.","description": "Base SAS provides a scalable,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"
    },"keywords": "base sas,virtualnuggets","prices": {
        "Training": "USD 0"
    },"workflow_state": "reported_on","venue": {
        "id": 26319,"name": "station road","address_1": "station road","town": "Sandwell","postcode": "B71 4HJ","latitude": 52.5273431,"longitude": -1.9883300652359
    },"contact": {
        "name": "Contact Name 43585","email": "contact43585@example.com","tel": "123456789"
    }
}]

*** 更新 ***

JSON 代码在它周围丢失了 [ ],它现在将通过第一次迭代并在第二次遇到 Object required: 'oJSON.data(...).Item(...)' 时出现 Set this = oJSON.data("events").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 和缺少括号有关 - 哎呀!希望这对某人有所帮助。

  1. Flakes 在评论中的建议解决了 CLNG 问题 - 谢谢。

  2. 循环示例 - 这里是完整代码。

    strJSON  = "{""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,""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"",""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""},""keywords"":""base sas,sas,online training,virtualnuggets"",""prices"":{""Training"":""USD 0""},""workflow_state"":""reported_on"",""venue"":{""id"":26319,""name"":""station road"",""address_1"":""station road"",""town"":""Sandwell"",""postcode"":""B71 4HJ"",""latitude"":52.5273431,""longitude"":-1.9883300652359},""contact"":{""name"":""Contact Name 43585"",""email"":""contact43585@example.com"",""tel"":""123456789""}}"

    'Wrap with "events" to turn it into a collection
    strJSON = "{""events"":[" & strJSON & "]}"

    Set oJSON = New aspJSON

    'Load JSON string
    oJSON.loadJSON(strJSON)

    'Loop through each record in the collection
    i = 0
    For Each eventrec In oJSON.data("events")
        
        'Shorthand access to each record
        Set this = oJSON.data("events").item(eventrec)

        'Access the base level items
        Response.Write i & ") " & this.item("id") & " = " & this.item("title") & "<br>"
        
        'Get Images
        bStop = False
        c = 0
        Do Until bStop
            If Len(this.item("image_urls").item(c)) > 0 Then
                Response.Write this.item("image_urls").item(c) & "<br>"
            Else
                bStop = True
            End If
            c = c + 1
        Loop
                
        'Links
        For Each link In this.item("links")
            Response.Write link & ":" & this.item("links").item(link) & "<br>"
        Next

        'Venue
        For Each link In this.item("venue")
            Response.Write link & ":" & this.item("venue").item(link) & "<br>"
        Next

        i = i + 1
    Next

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-