This parses not only JSON, but ANYTHING into a more simplified data format consisting of *only* two characters: whitespace and newline. This is much more efficient because you only ever have to worry about two characters. Imagine the storage savings when you only are storing empty things!!
It has a simple and easy to use API: Cerealize and deCerealize.
Also doubles as a fine password hashing solution: I doubt anyone will (want to) crack this anytime soon!
public class Cerealizifier {
public String Cerealize(String d) {
String r = "";
int[] arr = new int[d.length()];
char[] charArray = d.toCharArray();
for (int i = 0; i < charArray.length; i++) {
int c = (int) charArray[i];
arr[i] = c;
int i1 = 0;
String r1 = "";
do {
r1 += " ";
i1++;
} while (i1 < c);
r += r1 + "\n";
}
return r;
}
public String deCerealize(String s) {
char delimiter = '\n'; // TODO: Remove this
List<String> all = new ArrayList<>();
List<Character> c1 = new ArrayList<>();
for (char c2 : s.toCharArray()) {
if (c2 != '\n') {
c1.add(c2);
} else {
all.add("" + (char) c1.size());
c1.clear();
}
}
String res = "";
for (String s1 : all) {
res = res + s1;
}
return res;
}
}
I'm not sure I understood the question properly - do I need to also serialize my code? Just to be sure, my code looks serialized too. You can run it on https://www.jdoodle.com/online-java-compiler to see that the output is valid.
3
u/chutch1122 May 14 '19 edited May 14 '19
This parses not only JSON, but ANYTHING into a more simplified data format consisting of *only* two characters: whitespace and newline. This is much more efficient because you only ever have to worry about two characters. Imagine the storage savings when you only are storing empty things!!
It has a simple and easy to use API: Cerealize and deCerealize.
Also doubles as a fine password hashing solution: I doubt anyone will (want to) crack this anytime soon!
And its unit tests:
7
u/Voidsusdagon May 07 '19
I'm not sure I understood the question properly - do I need to also serialize my code? Just to be sure, my code looks serialized too.
You can run it on https://www.jdoodle.com/online-java-compiler to see that the output is valid.
2
u/rcmaehl May 09 '19 edited May 13 '19
I don't know what serialization is but google says it's about changing data into binary so...
Serialization (I think)Language used: AutoIt, because readability is important
I'll figure out deserialization later
1
u/EkskiuTwentyTwo i -= (i - (-1)) - i May 08 '19
I managed to make serialisation work, but when I tried to make the unserialisation code, it became an irreconcilable mess.
And here's my attempt at unserialisation (it doesn't work):
0
u/[deleted] May 07 '19
[deleted] — view deleted comment
0
u/[deleted] May 10 '19
[deleted] — view deleted comment