带空格的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
最满意答案
是的,是否使用其他专用服务器并不取决于您的网站必须处理多少流量。 如果您正在处理图像将它们存储在另一台服务器并保持根服务器清洁是个好主意。
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一定不能使用 ...
-
使用(socket.io + RedisStore)跨多个服务器进行通信(Using (socket.io + RedisStore) to communicate across multiple servers)[2023-02-27]
您不能直接向其他服务器上的套接字对象广播。 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 ... -
将Lua客户端连接到Socket.io NodeJS服务器?(Connecting a Lua client to a Socket.io NodeJS server? [closed])[2023-02-07]
如果你只想使用套接字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.