Setting Angles Between Bones
Use matrices.

In Python, How to get pose bone to rotate with another pose bone from a different armature? Finding Rotational difference  have shown how to snap a bone to another using world space matrices of each.  The example snaps one bone to the world space rotation of another.
Similarly here could look at local space. Have simply converted the local space matrix back to pose and applied to bone. Bit hard to test without two rigs, but as shown in linked answer, and Python How to make pose bone rotation toward a point?  can make matrix to adjust the rotation of the target pose bone to the source. Basically the rotation part of a pose matrix is pointing the Y axis of the bone (head - tail). If a bone is connected it will ignore the location part of its matrix
import bpy
from bpy import context
from mathutils import Matrix
import json

# WRITE

def pose2local(pb):
    M = pb.id_data.convert_space(
        pose_bone=pb,
        matrix=pb.matrix,
        from_space='POSE',
        to_space='LOCAL'
        )
    return [row[:] for row in M]

scene = context.scene
rig1 = scene.objects.get(&quot;Armature&quot;)

output = {pb.name : pose2local(pb)
        for pb in rig1.pose.bones}

with open(&quot;matrices.json&quot;, &quot;w&quot;) as fp:
    json.dump(output, fp)      


# READ

rig2 = scene.objects.get(&quot;Armature.001&quot;)

with open(&quot;matrices.json&quot;, &quot;r&quot;) as fp:
    data = json.load(fp)

def local2pose(pb, matrix):
    return pb.id_data.convert_space(
        pose_bone=pb,
        matrix=Matrix(matrix),
        from_space='LOCAL',
        to_space='POSE'
        )


for name, matrix in data.items():
    pb = rig2.pose.bones.get(name)
    if pb:
        pb.matrix = local2pose(pb, matrix)