简体   繁体   English

数组数据格式Redis pub子通道

[英]Array data format redis pub sub channel

I am trying to publish a normal javascript array on a redis channel through node eg- [1,2,3]. 我正在尝试通过节点eg- [1,2,3]在redis通道上发布普通的javascript数组。 Which i am then capturing through predis by subscribing to the same channel. 然后,我通过订阅同一频道来通过predis捕获。

However the data always shows up as [object Object]. 但是,数据始终显示为[object Object]。 I have tried json stringify but parsing or on print_r the variable still shows up as [object Object] in php. 我尝试了json stringify,但是在php上解析或在print_r上变量仍显示为[object Object]。

Anything that i am overlooking? 我忽略了什么?

Just make sure you are not using toString() method anywhere to convert your array into a string. 只要确保您没有在任何地方使用toString()方法将数组转换为字符串即可。 [object Object] is exactly what you'd expect if you use toString() instead of JSON.stringify() 如果使用toString()而不是JSON.stringify()[object Object]正是您所期望的

Fixed the issue. 解决了该问题。 There was a problem with the json structure. json结构存在问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM