package Ġcom . l hw dev . json . serialization Ċ Ċ import Ġcom . l hw dev . json .* Ċ import Ġkotlinx . serialization . Deserialization Strategy Ċ import Ġkotlinx . serialization . Experimental Serialization Api Ċ import Ġkotlinx . serialization . Serialization Strategy Ċ import Ġkotlinx . serialization . String Format Ċ import Ġkotlinx . serialization . modules . Empty Serial izers Module Ċ import Ġkotlinx . serialization . modules . Serial izers Module ĊĊ Ċ @ Opt In ( Experimental Serialization Api :: class ) Ċ class ĠJson Adapter ( Ċ ĉ val Ġconfig : ĠJson Config , Ċ ĉ override Ġval Ġserializers Module : ĠSerial izers Module Ġ= ĠEmpty Serial izers Module Ċ ) Ġ: ĠString Format Ġ{ Ċ ĉ override Ġfun Ġ< T > Ġdecode FromString ( de serializer : ĠDeserial ization Strategy < T >, Ġstring : ĠString ): ĠT Ġ{ Ċĉ ĉ val Ġtokenizer Ġ= ĠJson Tokenizer Clone able ( config , Ġstring . clone able Iterator ()) Ċĉ ĉ val Ġparser Ġ= ĠJson Any Parser ( config , ĠP eek able Clone able Iterator ( tokenizer )) ĊĉĉĊĉ ĉ val Ġdecoder Ġ= ĠJson Any Decoder ( this , Ġparser ) Ċĉ ĉ return Ġdecoder . decode Serializable Value ( de serializer ) Ċ ĉ } ĊĉĊ ĉ override Ġfun Ġ< T > Ġencode ToString ( serializer : ĠSerialization Strategy < T >, Ġvalue : ĠT ): ĠString Ġ{ Ċĉ ĉ val Ġoutput Ġ= ĠStringBuilder () Ċĉ ĉ val Ġwriter Ġ= ĠJson Any Writer ( config , Ġoutput . to Char Output ()) ĊĉĉĊĉ ĉ val Ġencoder Ġ= ĠJson Any Encoder ( this , Ġwriter ) Ċĉ ĉ encoder . encode Serializable Value ( serializer , Ġvalue ) Ċĉ ĉ return Ġoutput . toString () Ċ ĉ } ĊĉĊ ĉ fun Ġdecoder From Stream ( iterator : ĠClone able Char Iterator ) Ġ= Ċĉ ĉ Json Any Decoder ( this , ĠJson Any Parser ( config , ĠJson Tokenizer Clone able ( config , Ġiterator ))) ĊĉĊ ĉ fun Ġencoder To Stream ( output : ĠChar Output ) Ġ= Ċĉ ĉ Json Any Encoder ( this , ĠJson Any Writer ( config , Ġoutput )) Ċ } Ċ