对于亚行的逗号外壳转义字符 [英] adb shell escape character for comma

查看:307
本文介绍了对于亚行的逗号外壳转义字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过ADB工具模拟广播的意图,
其中一个意图额外价值是JASON,
杰森字符串第一个逗号后破碎,我没有得到该字符串的其余部分。

I am emulating a Broadcast Intent via ADB Tool, One of the intents extras value is a JASON, The Jason string is broken after the first comma and I'm not getting the rest of the string.

我使用的shell命令:

The shell command I am using:

adb shell am broadcast -a com.google.android.c2dm.intent.RECEIVE -n com.example.fx/com.example.fx.utils.gcm.GcmBroadcastReceiver --es "custom" "{"time":"2014-12-08T15:11:19,event_type":"m","event_id":"1418051429_1418051479"}"    

在code我用得到的意图字符串:

The code I use to get the string from the intent :

String payload = intent.getStringExtra("custom");    

结果我得到:

 "time:2014-12-08T15:11:19"    

有谁知道为什么发生这种情况,并围绕它的方式?

Does anyone know why this happens and a way around it?

在此先感谢

推荐答案

有同样的问题,解决它使用 亚历P上。 的<一个href=\"http://stackoverflow.com/questions/27375731/adb-shell-escape-character-for-comma/29053693#comment43215718_27375731\">comment:

Had the same problem, solved it using Alex P.'s comment:


  1. 请确保您开关 反之亦然在您的原始JSON字符串。

  1. Make sure you switch the " with ' and vice versa in you "raw" JSON strings.

请确保你的不可以使用`在你的字符串。

Make sure you're not using ` around your strings.

请确保您的字符串的最外层包装由

Make sure that the outer-most "wrapper" of your string consists of '.

此的没有的作品

To summarize:

This didn't work:

... --es "data" "{'buttons': [{'interaction': 'open', 'label': 'Show'},
 {'interaction': 'less', 'label': 'Less of this'}]}"

此的没有的作品

This did work:

... --es "data" '{"buttons": [{"interaction": "open", "label": "Show"},
 {"interaction": "less", "label": "Less of this"}]}'

这篇关于对于亚行的逗号外壳转义字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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