Peculiar Java JSON serializer problems

Finally, in my Semantic Web developer career, I got to that point when I had to do some work with JSON in Java. And as it goes, typically one needs to read some JSON, from an API, and make it available in a POJO (deserialize) and vice-versa (serialize).
The only requirement I had, was to avoid using annotations of any kind, such as @JsonProperty or @JsonDeserialize. Let’s take as an example a JSON object describing a person:

Please notice the @name property and that the degree property is a nested JSON object which can contain a different number of sub-properties, not known in advance.

First, we deserialize the above JSON into a Person POJO, then some data gets changed, and then it gets serialized back to a JSON object.

The POJO of the above example JSON is called Person.java and looks like this:

The focus is now on the serializing of this POJO.

Since I could not use annotations (@JsonProperty or @JsonDeserialize), I had to write a custom serializer or adapter (depending on which JSON library is used). This is where the peculiarities started.

My solution is written for both libraries: Jackson and JSON-B with Yasson. Next, I will exemplify them.

Let’s start with Jackson.

I pulled in Jackson version 2.13.4 from Maven and started with a Custom Serializer. The custom serializer needs to override the serialize method of the extended StdSerializer<Person> class. In the serialize method is where the customization happens:

Above, I am attempting to write the degree property, which in the POJO is of type Map<String, Object>, out as a string. This ends up being serialized as a JSON as follows:

did solve the @name property but the degree property is quite wrong! It is a String.

So how can this be improved with Jackson?

The solution is to use writePOJOField(). The exact and correct code looks like follows:

Awesome! Solved it for Jackson. Find the full code on GitHub.

Let’s see the solution also using JSON-B.

I have the same requirement: to not use any annotations. For this, I pulled in the JSON-B 1.0.2 version from Maven central and Yasson 1.0.3.

In the case of JSON-B, I needed to write an adapter to deal with the @name property. As goes, the adapter needs to override the adaptToJson (serialize) and adaptFromJson (deserialize) methods from the JsonbAdapter<Person, JsonObject> interface. So, the first go at it looks like the following (and I only focus on the adaptToJson method here):

If we take a look at the serialized JSON, we have again the same problem as with Jackson. The @name property is ok but the degree property is wrong again! The generated JSON looks like follows:

So how can this be done any better?
While in Jackson we had the brilliant writePOJOField method, JSON-B does not have such a method. My idea was for the adaptToJson method to use a helper method called addRightJsonType. So the correct adaptToJson is:

And the helper method addRightJsonType is a recursive method, that tries to catch all possible types of the entry value and deal with it accordingly:

Find the complete code on GitHub, which includes also the code for adaptFromJson method.

Conclusion

When I set out to serialize JSON in Java, little did I know that this task will come with some peculiarities. Writing a Jackson serializer or a JSON-B adapter means one needs to specify in detail how each property is to be handled. There are no shortcuts like using .toString() on a Map<String, Object> degree property. For some reason, I initially thought that by simply omitting it completely, it would still magically know how to deal with it 😅.

I also see how Jackson, by having a dedicated writePOJOField method, can be considered the most mature Java JSON parsing library. I also say this, because while searching online for solutions, other libraries also had the same problems as Yasson: no dedicated method to do this simple task.

Remark: for code simplicity, some if statements were omitted in the above code. See the full code on GitHub.

My personal opinion about Solid

I was thinking hard about how to explain Solid best. I like explanation videos. And because I am not talented at creating them and because someone already did a great job, I simply share one I like.

What is Solid?

Why a new Web in the first place?

As the Web is today, there are a few problems. The ones that bother me the most are:

Openness and accessibility

I have a Facebook account. If I want to share a social media update with a friend who does not have Facebook, I need to make it public and thus available for everyone to see it. That is not open nor accessible! Who creates this rule? The service provider, Facebook. Facebook owns my social circle.

Censorship and privacy

The truth is, my data, in whatever service it is on, could be sold to companies I would not know about it maybe. Everyone knows by now ‘if the service is free you are paying with your data. The service I have my data on can chose to do whatever because they are the authority. They can decide tomorrow that all data that contains the word ‘poop’ is going to be censored and deleted. And if I want to continue using their service, if I am not already banned, I need to sign their new Terms & Conditions.

What do people say about Solid?

Looking online at the general concerns about Solid I try to give my personal 5 cents about them and thus complete the image of what Solid is and can become.

How are data-thirsty companies going to buy into Solid?

At first, they will not. Not as long as their business model is based on monetizing user’s data. However, if they are smart, they will have/already have solutions in place to keep their business successful without owning so much data.

Recently I looked into the Amazon business case. One can see that their business is shifting or at least they have a strategy in place to help them be resilient in the face of such a data privacy change. I think their strategy is to become the ultimate service/experience provider in retail. They will not care where the data will be stored since their competitive advantage will be to offer the best service. For example, Amazon can provide the ultimate shopping experience based on tech (see Amazon Go). Don’t get stuck on the Amazon Prime account – that could well be your WebID. And do not get stuck on payment. Your WebID could contain your preferred payment method which your bank trusts and ultimately allows the transaction. In the end, you could be using Amazon Go which just happens to be, in the future, the go-to system in all shops…

And why would Amazon Go be the best system in place? The concept itself is not based on data, on your data. It is based on shopper needs which right now seems to be about ‘time’: ‘no line, no checkout’. Yes the ML and AI are based on data but that data will continue to be available as research data or Amazon could buy it from you.

If you notice, Solid could shift the focus from a business model based on the heaps of data to a business model based on best service quality.

How are data-thirsty companies going to buy into Solid? Take Two.

Because of YOU!

If we start to have choices that are based on the best service provider, best safe Pod host, best UX and accessibility, best experience, the data collecting giants will be left behind. They will have no choice but to change strategy and get in line with what the little people want. We might be little but we are billions, we are the market.

What keeps companies from simply copying your data? And keeping it?

They can do that now. And they could maybe do that in the future too until I, the user, pull the plug and with that, they will get no more up-to-date data about me. Current business models driven by data mean that the data is up to date, near real-time. This is very important because if they have my data from last year it will be majorly outdated when it comes to saying: my book purchase preferences, or fashion or whatever! I argue that the value of data is in its freshness.

And also, I hope, there will be policies and laws in place that will not allow this. Because if the market asks for the best quality in a service provider and we hear about privacy concerns we will deregister, cut the data plug and move to the next most secure service provider.

How about security concerns of Pods being individually hacked?

This is a good valid point! The premise is that a hacker would target individual Pods. Hmm… might not pay off. Let’s say that a hacker can hack more Pods at the same time because of a loophole in the tech. Pretty much what is happening right now! So how is that a bigger concern than how it is now?

My final thoughts

I think Solid will co-exist in parallel with the Web we have today. Nothing will change drastically and fast! We will keep having Social Media accounts, Amazon accounts, Google accounts, and data all over the place. However, we will have a new choice more privacy-sensitive. Diversity and inclusion is all about giving people choice.

My year of entrepreneurship

Preamble

In spring 2019 I applied and received a scholarship for an MBA at the Technical University of Vienna. I quit my job in autumn, same year, and travelled for a month before starting the MBA and a new job. The pandemic arrived a few month later and my job was a flop. What to do?

Intro

I decided I wanted for my MBA master thesis to write a business plan, the business plan to my own startup. So I took the path of entrepreneurship to learn it while doing it and to make the most of my MBA. Of course, at the beginning, the intention was to be successful and create my own work place and job description while also doing something good in the world. Now, after more than a year, I know it was an excellent learning adventure because it was not successful in the sense of creating a business.

The details about the entrepreneurship path, which includes Lean Design Thinking and our six ideas that were generated, are detailed in my master thesis. But the change that took place in me and the learning and self discovery, well that is a different story. Part of it I will try and write about it here.

Getting to the hard points

Taking part in several course and startup events to learn.

I tried a lot of startup opportunities offered in the Viennese community (and abroad) in 2020/2021. Some were better than others. Next I will mention some of them maybe it will help you.

First there was the 8-week startup course by RBL1, US based. I wanted to see what people in US learn in entrepreneurship. And I wanted to see what US startups were working on. Plus, the course was in beta version and I did not have to pay for it. It was interesting. It gave me the basics but I wanted to learn more.

Afterwards we got into the Impact Hub social accelerator for six month. This program was face to face, as much as possible, and it really conveyed a feeling of community. All the participating team were working on SDG problem. The mindset was amazing. We learned from one another and the workshops were tailored for starting startup like ours.

In parallel, we also did the WeDO5 good startup school where we learned about a different approach: the lean startup innovation methodology. And it was all about validation, validation, validation which we soooo underestimated.

We took part in the Circle17 Impathon where we worked on a proposed challenge brought to the program by the Austrian Development Bank. This was an intense long weekend, excellently organized! Everything was collaboratively done in Miro, remote and we had great fun!

At the Hacking4SDG startup course, organized by WeDo5 again, we had an intensive learning journey. We had the pressure to meet Alexander Osterwalder and Steve Blank. This course was all about validation, validation and validation again. Which we finally started to understand.

For the year 2021, we joined the Women AI Accelerate program and the SDG Innovation Lab. At this point, we were seven people in the team and we could split up in the courses which took place over several months. The Women AI Accelerate consisted of about 40 women interested in startups. The content was excellent! Each diverse topic, from law to AI programming to Public Relations, was delivered by top female and male experts. Some of the content was better than my MBA content!
For sake of completion of the list: we also took part in Startup Live in February 2021. And I want to mention the Vienna Business Agency which were absolutely lovely (compared to other Austrian institutions) and it offers great courses for entrepreneurs.

Next I will talk about what we did not join or what did not work for us.

We did not get into INITS in Vienna because we did not have a joint venture with a University or such. The UGP looked over the incomplete business plan and after two sessions, rejected me from their support and program. Then, we did get into Founder’s Institute but decided at that point, start of 2021, that we could not commit to the intense program and its expectation.

And in March 2021 we got the delayed answer from FFG that we got the Impact Innovation grant we have applied for in October 2020.

Conclusions:

There are a lot of programs and events out there. Each have their different levels of knowledge and expectations. But not all of them are good. What they all have in common: they demand your time. And your time is really valuable! Make wise decisions and inform yourself beforehand. And when possible, try to find out what you need and what fits to your state of startup you are in before joining. Have goals for each one.

Desperately trying to make sense of my personality in the hope I can work better together with my co-founder.

Some of the time in the co-founding team was dedicated to us, our communication, our mentoring each other and getting to know each other. It was hard to try keep this up but we managed I would say. This was not the problem.

We started with the MBTI personality test. I mean I even read the book about it, several times. And I tried to explain what it all means, to my co-founder… how I embody the INFJ type indicator. Well… that was not quite enough. Our friction problems were unfortunately not simply solved with this know how. Then we did some two more personality type tests, I am afraid I do not remember their names because they were not so good. And in the end we also learned about DISC. DISC is interesting! It resonated with me a lot. And it is probably quite useful if one would not be a ‘chameleon’. It turns out I can adapt to all four types of DISC when need be. And still…

One of the igniting reasons, the biggest reason for me, the startup failed, is because the team fell apart. I tried to think about it to learn why it did in the hope to avoid it next time around. Well… I suppose, like in marriage or any relationship: when it is a bit harder than it should be, at the beginning already, it is a sign this is not it. And if one learns to listen to the gut feeling more instead of being afraid to be a solo entrepreneur, one could avoid sooner the unavoidable.

Conclusion:

Personality types do not replace the gut feeling you are trying to avoid. They can also not explain what is going wrong 100% in your communication or misalignment. Instead of spending time here and there, just spend time with yourself and ask yourself truly: Is this what I want? Is this feeling good? Are we aligned? If more than one answer is a “no” then maybe you should call it out: next!

Austrian services to found a business almost killed me.

Oh wow! This which I expected to be easy, turned out to be soooo annoyingly hard. There is either too much or too little information online. Calling blindly WKO made matters worse.

To the point: we did not know what legal form we could create in our situation and to get the information was tedious. We did no know if we need a lawyer first or an accountant or what. To this day, I do not know why it was so hard! But I was disappointed! Even the equity split discussions were easier than this.

Conclusion:

The accountant knows more than you think and probably you need to go first to her. Not everyone will be kind and helpful, brace yourself.

Knowing when to CALL IT A DAY.

At the end, I had to do a very hard decision in my life: say ‘no’ to a 150k grant. Why this was necessary I will explain next.

We were decided to be three co-founders and to found a GmbH. We had a 30% equal split and 10% employee equity with a four year vesting period and a 25% cliff after one year. We even figured out we needed an accountant and we got a draft for a formal founder’s agreement. And then, the team fell apart. One founder backed out and the other two as well (including me). I want to say this was not the reason but it was the ignition.

I always said (at least to myself) I do not want to go this path solo. I wanted a partner, eye level, to share motivation, enthusiasm, responsibility and risk, equally. However, ‘equally’ is a funny thing! Yes, we did split equity equally but I started to have doubts that I was getting into business with someone on the same eye level. Doubts started creping in, in my bones. And what do you have as an entrepreneur when you start to not believe in your journey? Not much I tell you.

To make matters worse, I started to have anxiety in the form of shortness of breath already back in February 2021, almost every day. And that was my body telling me already back then, that things are not ok. I ignored my gut feeling and then it started to manifest physically.

Conclusion:

Never, never ignore gut feelings. They are the first signal about something being wrong. Not even team coaching can fix a founders relationship which is not meant to be, if problems are there from quite an incipient phase. Startups should be fun! When one forgets the fun and it is stress 24/7… well… I don’t know.

Some good takeaways

  1. You can only learn while going threw it. And you will learn more than you ever thought you can.
  2. Go threw it! You cannot imagine how many things you will learn: about yourself and about entrepreneurship.
  3. There is a wonderful new world with welcoming people awaiting in the entrepreneurship ecosystem.
  4. Take your time to choose your co-founder.
  5. Try to have a north star and not to loose your way (your values and/or purpose).

8 times more likely to achieve better business outcomes

Who does not want that?

EVERYONE wants that! And more:

  • twice as likely to meet or exceed financial targets
  • three times as likely to be high-performing
  • six times as likely to be innovative and agile

How does a company achieve this, you may ask? SUPER simple!

By creating an inclusive environment.

And this is where the cookie crumbles!

  • “I do not know what inclusive means”
  • “It is not aligned with business goals”
  • “I do not believe this works”
  • “We do not have time for this right now”

It turns out is is not so hard! Like Marlow’s pyramid you need to start with the pyramid base and add until you reach the TOP. The good news is: it only has 3 steps.

Inclusive culture 3 steps

I worked in IT companies all my professional life (10 years) so here are my suggestions for IT companies:

COMFORTABLE

  • Improve your Performance Interviews to be FAIR (actually helps drive equal pay)
    • fair means: have a worked out mathematical formula. It is not so important what that formula is as much as it is important that YOUR employees knowing there IS ONE!!! (it is a darn good start)

CONNECTION

Only and only if you have worked out the previous point continue working on this one. Remember it is a pyramid.

  • Offer opportunities for different social activities, and NO, going to a beer is not inclusive and soooo not enough.
    • Have you tried: hiking, escape the room, beach volleyball, cooking, helping out at a shelter or volunteering together for a better cause? You get the point…
    • Do not be shy to invite also people from other departments! It really really really helps!

CONTRIBUTION

Only and only if you have worked out the previous point continue working on this one. Remember it is a pyramid.

If you think comfort and connection was hard to achieve, you better give up now.

  • Are employees really involved in your decisions?
    • Have you asked them what would be a good work from home guideline or did you just slap it on them?
    • Have you asked them if the interface makes any sense to a woman? How about a child? How about a visually impaired person?
    • Have you asked them what your company values mean to them? Do you even have any? (NO? perfect! you have the amazing opportunity to make them collaboratively! You have values already? Can you afford to change any or add?)
  • Do you value the people who drive your business?
    • Do you, as the CEO, ever compliment them on a small contribution (in person)?
    • Do you have a down to earth, real life (NOT about business) (ones will say VULNERABLE) conversation with your employees?
    • Do you ever talk about the purpose of a task? Do you listen when they struggle with motivation? Do they even TELL YOU?

These are just some ideas I know would have helped me stay in my work place. Anyway, the more simple ones.

Still skeptical I see… Don’t take my word for it!!! Please read the Deloitte Belonging article. Just hot off the press (15 May 2020).

Make time to understand the implications you read there! If you just plan to skim through then don’t bother.

“8 times more likely to achieve better business outcomes

I really really don’t believe it is so hard. The only reason why I think it is not implemented yet is: “the day to day business is simply done differently in my company”.

Disclosure: quotes are not quotes from people I know. They are just my left shoulder talking to the right shoulder, trying to argument both sides 🙂

Cookie icon by Icons8

Exclamation Mark icon by Icons8

#hackthecrisisat

This weekend I decided to stop complaining about my throat and head ache over the week. And I stopped feeling useless. And I stopped feeling like work is everything I got. I decided to join an online hackathon!

Yup.. we are in the middle of it. It will finish tomorrow. And it feels great!!! My confidence, chipped away at work, is back! I felt valued and appreciated and grateful that my “generalist” skills (i call it so because I have confidence problems lately (Impostor Syndrome)) are useful to someone 🙂

My personal goal from the hackathon of learning something new and contributing was already achieved! I did not think it would be so easy actually. I loved to listed to ideas and find out about resources and have the opportunity to meet other people who know and like RDF.

Concretely: what at the beginning was a pile of ideas and wishes and divers points of view, I managed to converge to a concrete goal, a focus in the team. All the great ideas needed to be part of something achievable and deliverable in 2 days. I also jumped on installing SemanticMedaWiki on a EC2 AWS…. much like I learned from hosting my own website. (ieii happy about this one). Yup and I got to learn about SemanticMediaWiki.

The project is not over. Tomorrow is the great showdown with pitching and all… And I really want to get to know the input for the business model and the structure of the pitch. All super cool topics I am interested in lately.

In all this excitement I even forgot to mention what the project is about. Original idea:

Platform Eutopia
There exists no platform where one can get an overview about all the problems or bottlenecks we are facing at the moment in connection with the corona crisis and the possible solutions for those. And also with the people and connections that are already working on the problems.

More about the outcome:

See here the final project pitch presentation I ever did: https://www.youtube.com/watch?v=25yVp74U4ho&feature=youtu.be

Project website: https://evolution-circle.wixsite.com/website and the SemanticMediaWiki: http://54.93.194.43/wiki/Eutopia

Reference: https://hackthecrisis.bubbleapps.io/

P.s There are a bunch of hackathons on this topic all over the world. Not too late to join one, for example the upcoming global one: https://covid-global-hackathon.devpost.com/submissions

And more:

https://wirvsvirushackathon.devpost.com/submissions
https://changemakers-day-hackaton.devpost.com/submissions
https://endcoronavirus-org-hackathon.devpost.com/submissions
https://hackfromhome.devpost.com/submissions
https://freshworks-fights-covid.devpost.com/submissions
https://coronawiki.net/index.php?title=ALL_Projects
https://coronavz.com/