Just an idea! For code reduction maybe we can use this instead?
https://docs.juce.com/master/classJSON.html