本文介绍了如何将字符串添加到JsonArray的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在JsonArray中添加字符串值,然后创建Json String以在服务器上发送它.

I am trying to add string values in JsonArray and after that create Json String to send it on server.

我在Google上进行搜索,但找不到任何有用的信息.谁能告诉我该怎么做?谢谢

I was searching on google but I couldn't find anything helpful. Could anyone tell me how to this?Thanks

 JSONArray list = new JSONArray();
 list.put("Hello");
 list.put("Hey");

之后,我要创建JSONString

After that I want create JSONString

推荐答案

简单:

JSONArray list = new JSONArray();
list.put("Hello");
list.put("Hey");

String jsonString = list.toString()

根据文档,它应显示为[["Hello","Hey"]"

according to docs it should result in "["Hello", "Hey"]"

这篇关于如何将字符串添加到JsonArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 23:38