change json structure depending on existence of following parameter