Editor script to dump curves of animation clip to text file

I am looking for an editor script which can read all the curves from animation clip attached to the gameobject and log the keyframe / curve values to a text file.

After that, I can create AnimationClip runtime by reading the keyframe/curve data from the same text file. (This way I can modify any necessary property values if needed).

Is there a editor script available ? If not, kindly help me how I can write my own editor script to do this. Perhaps I have to use AnimationUtilty class for this.

I wrote such a script myself. It can be found here

In my next post, I will write a script which will use this JSON file to create animation clip at run-time and use it with game object(s).