kubernetes / client-go

Go client for Kubernetes.
Apache License 2.0
8.79k stars 2.91k forks source link

How to encode and decode objects to and from string? #1217

Closed jkhe-hub closed 1 year ago

jkhe-hub commented 1 year ago

I'm trying to find a way to encode and decode structs (such as corev1.Pod and corev1.Container) to and from strings. Since structs may contain pointers, so use Libraries directly such as json and yaml are not feasible. Is there an easy way to encode and decode these objects to and from strings? I found that client-go provides the String() method, but I did not find the corresponding decoding method.

Thank you very much.