繁体   English   中英

如何在JSON字符串中用大括号替换大括号?

[英]How can I replace curly braces with a real value inside a JSON string?

我正在开发一个Android项目。 在开发中,我使用Retrofit,Gson,RxJava。

例如,这样的答案可能会从我的服务器返回,并且我必须用大括号替换大括号。

{
    "text": "Hello {0} World {1} This is {2} test text"
}

您可以像这样使用MessageFormat

import java.text.MessageFormat;
MessageFormat.format("Hello {0} World {1} This is {2} test text", var1, var2, var3)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM