Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the json serializations of special characters

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article will explain in detail what json serialization of special characters has, Xiaobian thinks it is quite practical, so share it with you as a reference, I hope you can gain something after reading this article.

Let's take a look at a golang.

package mainimport ( "encoding/json" "fmt")func main() { data := map[string]string{ "str0": "Hello, world", "str1": "", "str3": "&", } jsonStr, _ := json.Marshal(data) fmt.Println(string(jsonStr))}

output result

{"str0":"Hello, world","str1":"\u003c","str2":"\u003e","str3":"\u0026"}

Let's start with rust.

extern crate rustc_serialize;use rustc_serialize::json;use std::collections::HashMap;fn main(){ let mut data = HashMap::new(); data.insert("str0","Hello, world"); data.insert("str1",""); data.insert("str3","&"); println! ("{}", json::encode(&data).unwrap());}}

results

{"str0":"Hello, world","str2":">","str1":"

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report