fix unsafe json creation by creating intermediate objects while creating patch bytes. Kubernetes-commit: dfde50b18564cc9a8e99fdcba2f136d770ec6943