I understand from your things that you transfer the string, so u want to translate a structure into a string. one way i think about is to convert the structure into bytes and then decode it back. for each structure you may need some signs, like: 123 mean start to transfer array. 221 mean start one array layer and 122 mean finish transfer the layer. etc.