More flexible JSON generation