Nodejs:查询中的数组的 url.parse 问题 [英] Nodejs: url.parse issue with arrays inside query

查看:39
本文介绍了Nodejs:查询中的数组的 url.parse 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

http://domain.com/action?params[]=1&params[]=2&params[]=3

返回:

query: { 'params[]': [ '1', '2', '3' ] }

params[] 作为名称而不是 params?

在 PHP 之后有点惊喜.

After PHP it's kinda surprise.

jQuery 序列化是在参数上添加 [] 顺便说一句.

jQuery serialization is adding [] on parameters btw.

你们是为此写了一个助手还是我做错了?

Are you guys wrote a helper for this or I'm just doing it wrong?

推荐答案

此模块根据需要进行解析:

This module does parsing as required:

https://github.com/visionmedia/node-querystring

如果这不起作用,还有另一个用于复杂数组:

There is another one for complex arrays if this doesn't work:

https://github.com/jazzychad/querystring.node.js

两者都在这里找到:https://github.com/joyent/node/wiki/modules

这篇关于Nodejs:查询中的数组的 url.parse 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆