RAFA BRAVO Active Member Licensed User Longtime User Sep 13, 2022 #1 Would it be possible to send several types by B4XSerializator? I would like to send and read a group of variables (this works fine) but then a different set of variables. Thank you
Would it be possible to send several types by B4XSerializator? I would like to send and read a group of variables (this works fine) but then a different set of variables. Thank you
DonManfred Expert Licensed User Longtime User Sep 13, 2022 #2 You can send ONE serialized Type at once. That said you can send any Type you want. But be sure that you deserialize the type into the correct one. Upvote 0
You can send ONE serialized Type at once. That said you can send any Type you want. But be sure that you deserialize the type into the correct one.
RAFA BRAVO Active Member Licensed User Longtime User Sep 13, 2022 #3 If I only need to send one type at a time DonManfred said: But be sure that you deserialize the type into the correct one Click to expand... I'm not sure about this part, any example to help me? Thank you Upvote 0
If I only need to send one type at a time DonManfred said: But be sure that you deserialize the type into the correct one Click to expand... I'm not sure about this part, any example to help me? Thank you
DonManfred Expert Licensed User Longtime User Sep 13, 2022 #4 RAFA BRAVO said: I'm not sure about this part, any example to help me? Click to expand... i don´t know a way to recognize the type. No. I suggest to create ONE Type with all the infos you need or not need and always send the same type. So you can expect the same type coming in. Upvote 0
RAFA BRAVO said: I'm not sure about this part, any example to help me? Click to expand... i don´t know a way to recognize the type. No. I suggest to create ONE Type with all the infos you need or not need and always send the same type. So you can expect the same type coming in.
Magma Expert Licensed User Longtime User Sep 13, 2022 #5 ...You can send your Type of DATA... for example: Code: Copy Type theData (a1 as int, a2 as long, a3 as float, a4 as string) 'etc... ... dim a as theData a.initialize a.a1=100 a.a2=10000000000 a.a3=0.0012 a.a4="my data, your data..." Dim cx As B4XSerializator dim b() as byte=cx.ConvertObjectToBytes(a) Upvote 0
...You can send your Type of DATA... for example: Code: Copy Type theData (a1 as int, a2 as long, a3 as float, a4 as string) 'etc... ... dim a as theData a.initialize a.a1=100 a.a2=10000000000 a.a3=0.0012 a.a4="my data, your data..." Dim cx As B4XSerializator dim b() as byte=cx.ConvertObjectToBytes(a)
RAFA BRAVO Active Member Licensed User Longtime User Sep 13, 2022 #6 I was asking about having a better organization, and not sending so many variables at once. But if it's the best solution, I'll work with only one type, thank you Upvote 0
I was asking about having a better organization, and not sending so many variables at once. But if it's the best solution, I'll work with only one type, thank you
Magma Expert Licensed User Longtime User Sep 13, 2022 #7 RAFA BRAVO said: I was asking about having a better organization, and not sending so many variables at once. But if it's the best solution, I'll work with only one type, thank you Click to expand... you can have you own variables... those you want... only... and is just an idea... or you can make a map and send a map.... for example saying dim a as map a.initialize a.put("typeofvar","string") 'so changing the typeofvar with a string... saying what is... a.put("value","yourvalue") just an idea... Upvote 0
RAFA BRAVO said: I was asking about having a better organization, and not sending so many variables at once. But if it's the best solution, I'll work with only one type, thank you Click to expand... you can have you own variables... those you want... only... and is just an idea... or you can make a map and send a map.... for example saying dim a as map a.initialize a.put("typeofvar","string") 'so changing the typeofvar with a string... saying what is... a.put("value","yourvalue") just an idea...
RAFA BRAVO Active Member Licensed User Longtime User Sep 13, 2022 #8 It was my idea: Code: Copy Dim type As data1 (data1Ok As boolean, data1Num As int, data1Value As string) Dim type As data2 (dataOk As boolean, data2Num As int, data2Value As string) A ssuming I have many types and many variables in each type. my question was if more than one type could be serialized. If it is not possible, I will serialize a single type with many variables Upvote 0
It was my idea: Code: Copy Dim type As data1 (data1Ok As boolean, data1Num As int, data1Value As string) Dim type As data2 (dataOk As boolean, data2Num As int, data2Value As string) A ssuming I have many types and many variables in each type. my question was if more than one type could be serialized. If it is not possible, I will serialize a single type with many variables
DonManfred Expert Licensed User Longtime User Sep 13, 2022 #9 You can create a List, add a Map to the list which also explains the type so you know what type is in the Map. B4X: Copy dim l as List l.initialize Dim m as map m.initialize m.Put("Type", "Type1") m.Put("TypeObject", mytype1object) l.put(m) Dim m as map m.initialize m.Put("Type", "Type2") m.Put("TypeObject", mytype2object) l.put(m) and then serialize the list.... Upvote 2
You can create a List, add a Map to the list which also explains the type so you know what type is in the Map. B4X: Copy dim l as List l.initialize Dim m as map m.initialize m.Put("Type", "Type1") m.Put("TypeObject", mytype1object) l.put(m) Dim m as map m.initialize m.Put("Type", "Type2") m.Put("TypeObject", mytype2object) l.put(m) and then serialize the list....
RAFA BRAVO Active Member Licensed User Longtime User Sep 19, 2022 #10 Perfect, he tried it and this was what he was looking for Upvote 0