[Servicestack. text]. Net serialization and deserialization components (claim to be the fastest, supporting JSON, XML, and jsv formats)

Source: Internet
Author: User
Tags net serialization tojson

Home page:

Https://github.com/ServiceStack/ServiceStack.Text

The home of. Net's fastest JSON, jsv and CSV text serializers.

Servicestack. Text isIndependent, dependency-freeSerialization library that contains all of servicestack's text processing functionality, including:

    • Jsonserializer
    • Typeserializer (jsv-format)
    • Csvserializer
    • T. Dump Extension Method
    • Stringextensions-XML/JSON/CSV/URL encoding, baseconvert, rot13, Hex escape, etc.
    • Stream, reflection, list, datetime, etc extensions and utils

Supports custom builds for:. Net 3.5 +, Mono, monotouch/monodroid, Silverlight 4/5, Xbox, Windows Phone 7

All in a single144kbDependency-free servicestack. Text. dll

 

experiment Code :

// Filename: user. csusing system; using system. collections. generic; using system. LINQ; using system. text; namespace consoletestapp. servicestack. redis. domain {public class user {public int num {Get; set;} public string name {Get; set;} public decimal weight {Get; set;} public datetime birthday {Get; set;} public override string tostring () {return string. format ("hashcode: {0}, num: {1}, name: {2}, Wei Ght: {3}, birthday: {4} ", this. gethashcode (), num, name, weight, birthday) ;}}// filename: program. csusing system; using system. collections. generic; using system. LINQ; using system. text; using consoletestapp. servicestack. redis. domain; using servicestack. text; namespace consoletestapp. servicestack. redis {class program {static void main (string [] ARGs) {user u = new user (); U. num = 110; U. name = "James"; U. we Ight = 58.3 m; U. birthday = datetime. parse ("02:03:04. 567 "); console. writeline ("############ JSON ##################"); string ujson = u. tojson (); console. writeline ("U. tojson (): "+ ujson); console. writeline ("jsonserializer:" + jsonserializer. serializetostring (u); // same as the extension method, user udejson = ujson. fromjson <user> (); console. writeline ("JSON deserialization:" + udejson. tostring (); console. writeline ("##### ######### XML ############### "); string uxml = u. toxml (); console. writeline ("U. toxml (): "+ uxml); console. writeline ("xmlserializer:" + xmlserializer. serializetostring (u); // same as the extension method, user udexml = uxml. fromxml <user> (); console. writeline ("XML deserialization:" + udexml. tostring ();/** jsv format (I. e. JSON-like separated values) is a JSON formatted red format that * uses CSV-style escaping for the least overhead And optimal performance. ** fastest and most compact text-serializer for. Net (5.3x quicker than JSON, 2.6x smaller than XML) * From: http://www.servicestack.net/mythz_blog? P = 176 */console. writeline ("############## jsv ################"); string ujsv = u. tojsv (); console. writeline ("U. tojsv (): "+ ujsv); console. writeline ("typeserializer:" + typeserializer. serializetostring <user> (u); User udejsv = ujsv. fromjsv <user> (); console. writeline ("jsv deserialization:" + udejsv. tostring (); console. writeline ("############## CSV ################"); string ucsv = u. tocsv (); console. writeline ("U. tocsv (): "+ ucsv); // user udecsvl = ucsv. (); // console. writeline ("CSV deserialization:" + udecsvl. tostring (); console. writeline ("\ n ############ typeserializer ##################"); string utypestring = typeserializer. serializetostring <user> (U); console. writeline ("typeserializer. serializetostring (): "+ utypestring); User ude = typeserializer. deserializefromstring <user> (utypestring); console. writeline ("original object:" + U. tostring (); console. writeline ("deserialization object:" + ude. tostring (); console. writeline ("Equal:" + U. equals (ude); console. readkey ();}}}

Packages. config

 <?  XML     Version  = " 1.0 "    Encoding  = " UTF-8 " ?>  <  Packages  >  <  Package     ID  = " Servicestack. Common "    Version  = " 3.9.43 "   Targetframework  = " Net40-Client " />  <  Package     ID  = " Servicestack. redis "    Version  = " 3.9.43 "    Targetframework  = " Net40-Client " />  <  Package     ID = " Servicestack. Text "    Version  = " 3.9.43 "    Targetframework  = " Net40-Client " />  </  Packages  > 

 

 

PS: Another good Library:

Http://json.codeplex.com/

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.