In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to change jsonobject to string". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to convert jsonobject to string".
Step 1: the console enters the information and receives the returned results
Scanner sc = new Scanner (System.in); while (true) String content = ""; / / console input information content = sc.nextLine (); / / receive the returned result String result = TuLingApiUtil.getResult (content)
Step 2: convert a string in json format to a json object
JsonObject json = new JsonParser () .parse (result) .getAsJsonObject ()
Step 3: get the contents of the text key and convert it to string
String back = json.get ("text") .toString
Output
System.out.println (back)
It should be noted that the null value is not output after jsonobject is converted to string.
For example
JSONObject jsonObject = new JSONObject (); jsonObject.add ("name", null); String str = jsonObject.toString (); / / {} str = JSONObject.toJSONString (jsonObject, SerializerFeature.WriteMapNullValue); / / {"name", null} Thank you for your reading. This is the content of "how to transfer jsonobject to string". After the study of this article, I believe you have a deeper understanding of how to transfer jsonobject to string, and the specific use needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.