首页 \ 问答 \ 带空格的JSON数据(JSON data with spaces)

带空格的JSON数据(JSON data with spaces)

我有以下JSON数据结构。 我想知道如何提取提供密钥的数据。

"Meta Data": {
    "1. Information": "High School",
    "2. Name": "St Marys"
},
"Teachers' Names": {
    "Grade I": {
        "1. English": "Amanda Fernandez",
        "2. Sociology": "Christina Andrew",
        "3. Applied Science": "George Binu"
    },
    "Grade II": {
        "1. English": "Gedfd Hkdfd",
        "2. Sociology": "lksdg klsdfd",
        "3. Applied Science": "some one else"
    }
  }
}

我使用nodejs并在请求模块下的“body”对象中获取这些数据。 我如何提取上面的一级英语教师姓名? 我尝试了身体[“教师姓名”[0]),看看它是否会给我至少一级的对象,但它没有。有人可以帮助我吗?


I have the following JSON data structure. I would like to know how could I extract the data providing the keys.

"Meta Data": {
    "1. Information": "High School",
    "2. Name": "St Marys"
},
"Teachers' Names": {
    "Grade I": {
        "1. English": "Amanda Fernandez",
        "2. Sociology": "Christina Andrew",
        "3. Applied Science": "George Binu"
    },
    "Grade II": {
        "1. English": "Gedfd Hkdfd",
        "2. Sociology": "lksdg klsdfd",
        "3. Applied Science": "some one else"
    }
  }
}

I use nodejs and get this data in a 'body' object under request module. How do I extract the Grade I, English Teacher name above? I tried body["Teachers' Names][0] to see if it would give me at least the Grade I object in full. But it didn't. Can someone please help me?


原文:https://stackoverflow.com/questions/47841380
更新时间:2023-04-30 22:04

最满意答案

是的,是否使用其他专用服务器并不取决于您的网站必须处理多少流量。 如果您正在处理图像将它们存储在另一台服务器并保持根服务器清洁是个好主意。


Well yes, Whether to use another dedicated server is not depending on how much traffic your site will have to handle. If you're dealing with images It will be a good idea to store them in another server and keep the root server clean.

相关问答

更多
  • 这个问题的答案是,您必须设置一个位于您的SocketIO群集之外的单个Redis服务器,并让所有节点都连接到它。 然后,只需将它添加到代码的顶部,它就可以在没有任何问题的情况下正常工作。 var io = require('socket.io')(server); var redis = require('socket.io-redis'); io.adapter(redis({ host: 'localhost', port: 6379 })); The answer to this question ...
  • 我认为这是一个合理而直接的方式; 似乎建议谨慎处理执行顺序,但这可能只是我对节点显示的不确定性。 I think that's a reasonable and straightforward way to go; it seems like caution would be advised for dealing with order of execution, but that's probably just my uncertainty with node showing.
  • Archie1986的答案是好的,但已经变得过时了socketio更新(更具体地说,它的协议: https : //github.com/LearnBoost/socket.io-spec )...据我所知,你需要执行握手在您可以要求运输(例如,websockets)连接之前手动注意下面的代码是不完整和不安全的...一个,它忽略在握手响应中返回的支持的传输列表,并始终尝试获取websocket ...也假设握手总是成功...但是,这是一个很好的开始 import websocket, httplib .. ...
  • 是的,是否使用其他专用服务器并不取决于您的网站必须处理多少流量。 如果您正在处理图像将它们存储在另一台服务器并保持根服务器清洁是个好主意。 Well yes, Whether to use another dedicated server is not depending on how much traffic your site will have to handle. If you're dealing with images It will be a good idea to store them i ...
  • 基于这个错误,我怀疑问题是你在服务器的CORS响应头中使用了一个通配符: res.header("Access-Control-Allow-Origin", "*"); 为什么这是个问题? 从文档 : 在响应凭证请求时,服务器必须在Access-Control-Allow-Origin标头的值中指定一个来源,而不是指定“*”通配符。 这是一个相关的StackOverflow答案 : 这是安全的一部分,你不能那样做。 如果你想允许凭证,那么你的Access-Control-Allow-Origin一定不能使用 ...
  • 您不能直接向其他服务器上的套接字对象广播。 Redis的功能是允许您在其他服务器上广播到“房间”。 值得庆幸的是,对于socket.io 1.x,新连接会自动加入一个房间,其名称为套接字ID。 要解决您的问题,请更改: if(socket_id){ var socket = io.of('/game').sockets[socket_id]; socket.emit("message", {sender : sender}); // This fails. Mess ...
  • 如果你只想使用套接字IO服务器尝试https://github.com/ignacio/LuaNode-Socket.IO 。 否则,你必须去一些本地websocket实现。 也看看这个SO If you want to try only with socket IO server then try https://github.com/ignacio/LuaNode-Socket.IO. Else you have to go with some native websocket implementati ...
  • 我还发布了Socket.IO的GitHub问题页面,并在那里得到了答案。 看起来我将使用Hook.IO来做我需要的事情。 谢谢! I also posted on Socket.IO's GitHub Issues Page and got an answer there. Looks like I will be using Hook.IO to do what I need. Thanks!
  • 目前尚不清楚你究竟在问什么。 当您将用户连接到各种服务器并且您希望将消息从一个服务器发送给特定用户时,您必须最终将该消息传递给用户所连接的服务器,以便它可以通过用户发送消息连接。 有多种方法可以做到这一点: 中央数据库。 维护一个中央数据库,告诉您在任何给定时间用户连接的服务器。 然后,当您想要向userA发送消息时,您可以在中央数据库中查找它们并发现它们当前已连接到Server12,然后您可以要求Server12将消息发送给它们。 这是socket.io redis解决方案使用的策略。 此策略可能会在中央 ...
  • 实际问题是redis在服务器中连接的端口被防火墙阻止。 The actual problem was that port on which redis was connecting in server was blocked by the firewall.

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)