urlencode

Java convert JSONObject to URL parameter

我们两清 提交于 2020-02-05 10:37:07
问题 What is the elegant way to convert JSONObject to URL parameters. For example, JSONObject: {stat: {123456: {x: 1, y: 2}, 123457: {z: 5, y: 2}}}} this should be like: stat[123456][x]=1&stat[123456][y]=2&stat[123457][z]=5&stat[123457][y]=2 of course with escaped symbols, and of course JSON object could be more complicated.. Maybe there already exist some mechanisms for that? Thanks, 回答1: Looks like, the only way I found it to make it manually. 回答2: If readability isn't a big concern, you could

Java convert JSONObject to URL parameter

三世轮回 提交于 2020-02-05 10:36:09
问题 What is the elegant way to convert JSONObject to URL parameters. For example, JSONObject: {stat: {123456: {x: 1, y: 2}, 123457: {z: 5, y: 2}}}} this should be like: stat[123456][x]=1&stat[123456][y]=2&stat[123457][z]=5&stat[123457][y]=2 of course with escaped symbols, and of course JSON object could be more complicated.. Maybe there already exist some mechanisms for that? Thanks, 回答1: Looks like, the only way I found it to make it manually. 回答2: If readability isn't a big concern, you could

Java convert JSONObject to URL parameter

≡放荡痞女 提交于 2020-02-05 10:36:07
问题 What is the elegant way to convert JSONObject to URL parameters. For example, JSONObject: {stat: {123456: {x: 1, y: 2}, 123457: {z: 5, y: 2}}}} this should be like: stat[123456][x]=1&stat[123456][y]=2&stat[123457][z]=5&stat[123457][y]=2 of course with escaped symbols, and of course JSON object could be more complicated.. Maybe there already exist some mechanisms for that? Thanks, 回答1: Looks like, the only way I found it to make it manually. 回答2: If readability isn't a big concern, you could

Cookie存中文乱码的问题

≡放荡痞女 提交于 2020-02-05 01:34:12
有个奇怪的问题:登录页面中使用Cookie存值,Cookie中要存中文汉字。代码在本地调试,一切OK,汉字也能顺利存到Cookie和从Cookie中读出,但是放到服务器上不管用了,好好的汉字成了乱码,原本以为是服务器环境和本地的不一样,后来一想应该不对,因为代码放服务器上之后再访问登录页面会和服务器交互,交互必然要有网络传输,而Cookie是存在本地的,就是在服务器向本地写Cookie的时候,网络的编码格式影响了汉字的正常存储导致汉字乱码。顺着这个思路改代码,然后测试,通过! 但是新问题来了,在给汉字编码的时候,常用的有这两种:HttpUtility.UrlEncode 和 Server.UrlEncode,虽然编码/解码成对使用没问题,但是毕竟是两种方法,总该是有区别的,网上查了一下,区别如下: 第一:引用: 1、HttpUtility.UrlEncode,HttpUtility.UrlDecode是静态方法,而Server.UrlEncode,Server.UrlDecode是实例方法。 2、Server是HttpServerUtility类的实例,是System.Web.UI.Page的属性。 3、用HttpUtility.UrlEncode编码后的字符串和用Server.UrlEncode进行编码后的字符串对象不一样 Server.UrlEncode

PHP urlencode 不得不说的秘密

只愿长相守 提交于 2020-02-04 10:44:26
PHP urlencode 方法可以算是使用率比较高的一个方法了。特别是在 API 接口设计的领域或使用其他第三方 API 的时候,经常会碰到使用 urlencode 的场景。 在几年前设计过一套 API 接口提供给 App 客户端调用。Android 客户端使用 Java 开发,他们会把参与按照文档定义的规则把参数名与值进行拼接之后再 urlencode 编码,然后再拼接上一个密钥 KEY 再 MD5 再转换为大写得到一个签名。服务器端收到这个请求之后,也会按照这个规则进行签名生成与客户端提交的签名进行判断。 结果问题就出来了。 // Android 客户端提交的信息如下: $params = [ 'method' => 'user.register', // 注册接口。 'v' => '1.0.0', // APP 版本号。 'mobile' => '14812345678', // 注册手机号。 'code' => '123456', // 短信验证码。 'password' => 'abcde fg' // 账号密码。注意这里带了一个空格。 ]; // 按照键名自然排序(升序)。 ksort($params); // 把键名与值拼接。 $str = ''; foreach ($params as $key => $value) { $str .= "{$key}{

Should I url encode a query string parameter that's an URL?

元气小坏坏 提交于 2020-02-03 03:02:06
问题 Just say I have the following url that has a query string parameter that's an url: http://www.someSite.com?next=http://www.anotherSite.com?test=1&test=2 Should I url encode the next parameter? If I do, who's responsible for decoding it - the web browser, or my web app? The reason I ask is I see lots of big sites that do things like the following http://www.someSite.com?next=http://www.anotherSite.com/another/url In the above, they don't bother encoding the next parameter because I'm guessing,

In ASP.NET, why is there UrlEncode() AND UrlPathEncode()?

混江龙づ霸主 提交于 2020-01-28 05:52:10
问题 In a recent project, I had the pleasure of troubleshooting a bug that involved images not loading when spaces were in the filename. I thought "What a simple issue, I'll UrlEncode() it!" But, NAY! Simply using UrlEncode() didn't resolve the problem. The new problem was the HttpUtilities.UrlEncode() method switched spaces ( ) to plusses ( + ) instead of %20 like the browser wanted. So file+image+name.jpg would return not-found while file%20image%20name.jpg was found correctly. Thankfully, a

how to make asp.net hyperlink to stop encoding the urls?

有些话、适合烂在心里 提交于 2020-01-25 09:57:05
问题 I have got a BulletedList with DisplayMode="HyperLink" . <asp:BulletedList runat="server" DisplayMode="HyperLink" ID="LevelsList"></asp:BulletedList> I add items to the list with this code: LevelsList.Items.Add(new ListItem(curSubPage.PageName, curSubPage.shortURL)); The URL links contain Hebrew strings and they get encoded: The markup the the asp.net generates is something like that: <a href="%d7%91%d7%a0%d7%99%d7%99%d7%aa_%d7%90%d7%a4%d7%9c%d7%99%d7%a7%d7%a6%d7%99%d7%95%d7%aa_%d7%90%d7%99

How to generate a Shift_JIS(SJIS) percent encoded string in JavaScript

走远了吗. 提交于 2020-01-24 22:57:29
问题 I'm new to both JavaScript and Google Apps Script and having a problem to convert texts written in a cell to the Shift-JIS (SJIS) encoded letters. For example, the Japanese string "あいう" should be encoded as "%82%A0%82%A2%82%A4" not as "%E3%81%82%E3%81%84%E3%81%86" which is UTF-8 encoded. I tried EncodingJS and the built-in urlencode() function but it both returns the UTF-8 encoded one. Would any one tell me how to get the SJIS-encoded letters properly in GAS? Thank you. 回答1: You want to do

Generating QR codes in google-spreadsheet

有些话、适合烂在心里 提交于 2020-01-24 22:04:48
问题 I have a simple question about generating QR codes with google-spreadhseet. I am using google's API call =image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl="&A3) This works fine. Where A3 is a persons first name. I have their last name in A4 but when I try: =image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl="&(A3+A4)) or =image("https://chart.googleapis.com/chart?chs=150x150&cht=qr&chl="& (CONCATENATE(A3, " ", A4))) The QR box is blank. How can I generate a QR