You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Note that Message is also SelfSerializable which makes it eligible to be serialized with SelfSerializableProtocol as well!
35
-
* You can try this by uncommenting this line and commenting line above, notice how data format will change slightly due to different serialization technique that SelfSerializable uses!
LogProvider.instance.setReThrowException(true); // This is for testing purposes, so no error are allowed in this case, comment temporary when necessary...
68
+
69
+
SerializationProtocol.REGISTRY.add(
70
+
SerializationProtocol.REGISTRY.removeIf(prot -> prot.applicableFor() == Message.class) ? // Change this accordingly while experimenting (add negation in front)...
71
+
72
+
/*
73
+
* Registering AutoProtocol for Message class and setting it to serialize it as Scope, but feel free to experiment (except when args are NO_SCOPE in case you are running this as test)!
* Note that Message is also SelfSerializable which makes it eligible to be serialized with SelfSerializableProtocol as well!
79
+
* You can try this by changing the condition above, notice how data format will change slightly due to different serialization technique that SelfSerializable uses!
80
+
*/
81
+
newSelfSerializableProtocol(Message.class)
82
+
);
38
83
39
84
Filemedium = newFile("src/examples/implementations/messages.json"); // Json file to use...
40
85
41
-
// Content to serialzie (list of Messages)
86
+
// Content to serialize (list of Messages)
42
87
List<Message> messages = newArrayList<>();
43
88
messages.add(newMessage("Hi!", 1));
44
89
messages.add(newMessage("My name is Json.", 2));
45
90
messages.add(newMessage("And I am data format!", 3));
91
+
if (Objects.deepEquals(args, newString[] {"str", "date", "mappedReplies"}))
92
+
messages.get(2).setMappedReplies(Scope.mapKvArray(newHashMap<>(), "entry1", newMessage("Hello to you as well from map!", 12)));
93
+
else
94
+
{
95
+
messages.get(0).setReplies(newArrayList<>());
96
+
messages.get(1).setReplies(newArrayList<>(Arrays.asList(newMessage("Hello to you as well!", 11))));
97
+
}
46
98
47
99
/*
48
100
* Creating new JsonSerializer object and putting out Messages into it.
Copy file name to clipboardExpand all lines: src/examples/implementations/test.juss
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
//Date created: 07-12-2024 at 21:57:29 CEST
1
+
//Date created: 07-18-2024 at 23:24:38 CEST
2
2
3
3
//Scope serialization summary:
4
4
//2 variables!
@@ -7,9 +7,9 @@
7
7
num = 6; //Primitive data type: "6" the integer value! Stored by "num" variable!
8
8
yourMom = "has an event horizon... //lol"; //Object of java.lang.String: "has an event horizon... //lol"! Stored by "yourMom" variable!
9
9
"some string"; //Object of java.lang.String: "some string"!
10
-
java.util.Random 68284896517770L; //Object of java.util.Random: "java.util.Random@52b1beb6" serialized using examples.implementations.GeneralExample$1[java.util.Random]!
10
+
java.util.Random 68284896517770L; //Object of java.util.Random: "java.util.Random@18df8434" serialized using examples.implementations.GeneralExample$1[java.util.Random]!
11
11
ArrayList 0 0 T 1 3 0 5 T 5 6 {java.util.LinkedList 0 0 T 1 3 0 5 T 5 6}; //Object of java.util.ArrayList: "[0, 0, true, 1, 3, 0, 5, true, 5, 6, [0, 0, true, 1, 3, 0, 5, true, 5, 6]]" serialized using org.ugp.serialx.protocols.ListProtocol[java.util.Collection]!
0 commit comments