P Priamo Member Licensed User Longtime User Oct 28, 2012 #1 Hi to all, i Would know if is possible to serialize a class into a string, and send it with a socket on the lan. After deserialize the string received from tha Astreams. Thanks.
Hi to all, i Would know if is possible to serialize a class into a string, and send it with a socket on the lan. After deserialize the string received from tha Astreams. Thanks.
Erel B4X founder Staff member Licensed User Longtime User Oct 28, 2012 #2 You cannot serialize it with RAF.WriteObject. You will need to implement the serialization yourself. You can however use a Type with the same fields, fill the type from the class and then serialize the type. Upvote 0
You cannot serialize it with RAF.WriteObject. You will need to implement the serialization yourself. You can however use a Type with the same fields, fill the type from the class and then serialize the type.
P Priamo Member Licensed User Longtime User Oct 28, 2012 #3 Hi, thanks for the answers. This is my code Code: Copy Dim cls as class1 cls.codice="678910" dim lst as List lst.Initialize lst.add(cls) Dim p as JSONGenerator p.Initialize2(lst) Dim a as string a=p.Tostring Dim Buffer() as byte Buffer =a.GetBiytes(("UTF8") AStreams.Write(Buffer) This is a part of the code of the app, here, how you can see, send a class serialized with Json to an app .Net on windows, this is the result that i receive: ["[bgkservice=null, codice=678910, kioskservice=null\n, main=null]"] the data arrive, but the format is strange not is JSon format. Now i want to deserialize on the server, but if the format is incorrect, how can i do? Upvote 0
Hi, thanks for the answers. This is my code Code: Copy Dim cls as class1 cls.codice="678910" dim lst as List lst.Initialize lst.add(cls) Dim p as JSONGenerator p.Initialize2(lst) Dim a as string a=p.Tostring Dim Buffer() as byte Buffer =a.GetBiytes(("UTF8") AStreams.Write(Buffer) This is a part of the code of the app, here, how you can see, send a class serialized with Json to an app .Net on windows, this is the result that i receive: ["[bgkservice=null, codice=678910, kioskservice=null\n, main=null]"] the data arrive, but the format is strange not is JSon format. Now i want to deserialize on the server, but if the format is incorrect, how can i do?
Erel B4X founder Staff member Licensed User Longtime User Oct 28, 2012 #4 The problem is in this line: Code: Copy lst.Add(cls) This will convert the class to a "debugging" string. If you want to use JSON then you will need to explicitly convert the class to a Map with the fields. Upvote 0
The problem is in this line: Code: Copy lst.Add(cls) This will convert the class to a "debugging" string. If you want to use JSON then you will need to explicitly convert the class to a Map with the fields.