How to import bone locations form a text file?
The script you have doesn't dump a lot of important information, like the bone roll, or parenting info.
Assuming you're trying to dump the editbone info, this script should work. By default it exports. Change command in the options at the top to 'IMPORT' to import instead.
# !!!! Options, edit me!
path = 'C:\\Bones.json'
command = 'EXPORT'  # EXPORT or IMPORT
# !!!!

import bpy
bone_props = [
    'name', 'head', 'tail', 'roll', 'use_connect',
    'use_local_location', 'use_inherit_rotation', 'inherit_scale',
]
if command == 'EXPORT':
    ob = bpy.context.view_layer.objects.active
    if ob and ob.type == 'ARMATURE':
        pass
    else:
        obs = [ob for ob in bpy.data.objects if ob.type == 'ARMATURE']
        if len(obs) == 1:
            ob = obs[0]
        else:
            raise RuntimeError('Select an armature')
    arma = ob.data

    data = {}
    data['armature'] = {}
    data['armature']['name'] = arma.name

    if bpy.context.mode != 'OBJECT':
        bpy.ops.object.mode_set(mode='OBJECT')
    bpy.context.view_layer.objects.active = ob
    bpy.ops.object.mode_set(mode=&quot;EDIT&quot;)

    data['edit_bones'] = []
    for ebone in arma.edit_bones:
        bonedata = {}
        bonedata['parent'] = ebone.parent.name if ebone.parent else None
        for prop in bone_props:
            val = getattr(ebone, prop)
            if prop in ['head', 'tail']: val = list(val)
            bonedata[prop] = val
        data['edit_bones'].append(bonedata)

    bpy.ops.object.mode_set(mode=&quot;OBJECT&quot;)

    with open(path, 'w') as f:
        import json
        json.dump(data, f, indent=2)

elif command == 'IMPORT':
    with open(path, 'r') as f:
        import json
        data = json.load(f)

    arma = bpy.data.armatures.new(data['armature']['name'])
    ob = bpy.data.objects.new(arma.name, arma)
    bpy.context.collection.objects.link(ob)

    if bpy.context.mode != 'OBJECT':
        bpy.ops.object.mode_set(mode='OBJECT')
    bpy.context.view_layer.objects.active = ob
    bpy.ops.object.mode_set(mode=&quot;EDIT&quot;)

    for bonedata in data['edit_bones']:
        arma.edit_bones.new(bonedata['name'])

    for bonedata in data['edit_bones']:
        ebone = arma.edit_bones[bonedata['name']]
        if bonedata['parent']:
            ebone.parent = arma.edit_bones[bonedata['parent']]
        for prop in bone_props:
            setattr(ebone, prop, bonedata[prop])

    bpy.ops.object.mode_set(mode=&quot;OBJECT&quot;)