Unity JSON parsing IPA follow-up

Source: Internet
Author: User

Previously mentioned, there are a lot of restrictions, can only parse the simple class, if the complex will have problems, from the foreigner where to see a blog, is the class list and other complex objects serialization,

usingUnityengine;usingSystem.Collections;usingSystem.Collections.Generic;usingSystem;//list<t>[Serializable] Public classSerialization<t>{[Serializefield] List<T>Target;  PublicList<t> ToList () {returnTarget;}  PublicSerialization (list<t>target) {         This. target =Target; }}//Dictionary<tkey, tvalue>[Serializable] Public classSerialization<tkey, tvalue>: iserializationcallbackreceiver{[Serializefield] List<TKey>keys;    [Serializefield] List<TValue>values; Dictionary<tkey, tvalue>Target;  PublicDictionary<tkey, tvalue> todictionary () {returnTarget;}  PublicSerialization (Dictionary<tkey, tvalue>target) {         This. target =Target; }     Public voidonbeforeserialize () {keys=NewList<tkey>(target.        Keys); Values=NewList<tvalue>(target.    Values); }     Public voidonafterdeserialize () {varCount =math.min (keys. Count, values.        Count); Target=NewDictionary<tkey, tvalue>(count);  for(vari =0; I < count; ++i) {target.        ADD (Keys[i], values[i]); }    }}//BitArray[Serializable] Public classserializationbitarray:iserializationcallbackreceiver{[Serializefield]stringflags;    BitArray Target;  PublicBitArray Tobitarray () {returnTarget;}  PublicSerializationbitarray (BitArray target) { This. target =Target; }     Public voidonbeforeserialize () {varSS =NewSystem.Text.StringBuilder (target.        Length);  for(vari =0; I < target. Length; ++i) {ss. Insert (0, Target[i]?'1':'0'); } Flags=SS.    ToString (); }     Public voidonafterdeserialize () {target=NewBitArray (Flags.        Length);  for(vari =0; I < flags. Length; ++i) {target. Set (Flags. LengthI1, flags[i] = ='1'); }    }}

Unity JSON parsing IPA follow-up

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.