【发布时间】:2017-11-09 10:10:32
【问题描述】:
我需要从Firebase 中远程config 的默认值中获取JSONObject。通过FirebaseRemoteConfig.getString(),它被转换为字符串,但不在JSONObject中,说
org.json.JSONException: Unterminated object at character xx
我在下面附上了远程config 的默认值:
<entry>
<key>welcome_message</key>
<value>{"version" :1,"type":"category","name":"CATEGORY"}
</value>
</entry>
我现在附上我的 Java 代码:
String welcomeMessage = mFirebaseRemoteConfig.getString(WELCOME_MESSAGE_KEY);
JSONObject categoryListInJson = new JSONObject(welcomeMessage);
提前感谢您的回答。
【问题讨论】:
-
Print String wc ,是不是格式正确的json?
-
不,不是@semako
-
可以贴一下welcomeMessage的内容吗?并且还在“org.json.JSONException:字符 xx 处的未终止对象”中,xx 的值是多少? @vipul-k-patil
-
我已经在问题中做到了这一点。字符串为:{version:1,type:category,name:BASE CATEGORY},“xx”的值为36,即空格符-“”
-
看起来xml标签值有json。
标签: java android json firebase firebase-remote-config