In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
This article introduces the relevant knowledge of "introduction and usage of kapok". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Introduction and use of kapok
Kapok is an excellent serialization library that serializes objects into strings in Json format. It also uses rapidjson open source projects to support SAX and DOM parsing.
GitHUb address: https://github.com/qicosmos/Kapok
GitHub address: https://github.com/miloyip/rapidjson
Because they are used in the project, the methods used are recorded here.
Usage
The method of using kapok is very simple and requires only three steps.
1. Add a serializable attribute # include "kapok/Kapok.hpp" to the object
Struct YourType {
Int a
Double b; std::string c
/ / get the meta-information of the object, which is a macro definition, which is actually a function META (a, b, c)} 2. Serialize object # include "kapok/Kapok.hpp"
YourType t = {1,2.2, "Hello"}
/ / create a serialized object
Serialize sr
/ / use sr to serialize the object t
Sr.Serialize (t)
/ / get the json string of the serialized object
Std::string json_str = sr.GetString (); 3. Deserialize object # include "kapok/Kapok.hpp"
/ / create a deserialized object
DeSerializer dr;YourType t
/ / as long as you parse the sr.GetString () format
/ / for example, you can send sr.GetString () to the client through the network on the server side.
/ / it is also possible for the client to parse and deserialize using dr.
Dr.Parse (json_str)
/ / deserialize to object t
Dr.DeSerializer (t); "introduction to kapok and how to use it" ends here. Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.