module CRigSize
    use SimulationVariables
    use json_module
    implicit none    
    public 
    contains

    subroutine RigSizeToJson(parent)

        type(json_value),pointer :: parent
        type(json_core) :: json
        type(json_value),pointer :: p

        ! 1. create new node
        call json%create_object(p,'RigSize')
        
        ! 2. add member of data type to new node
        ! call StringConfigurationToJson(p) 
        ! call FormationToJson(p)
        call json%add(p,"RigType",data%Configuration%RigSize%RigType)
        call json%add(p,"CrownHeight",data%Configuration%RigSize%CrownHeight)
        call json%add(p,"MonkeyBoandHeight",data%Configuration%RigSize%MonkeyBoandHeight)
        call json%add(p,"RigFloorHeight",data%Configuration%RigSize%RigFloorHeight)
        ! 3. add new node to parent
        call json%add(parent,p)
    end subroutine

    subroutine RigSizeFromJson(parent)
        use json_module,IK =>json_ik
        type(json_value),pointer :: parent
        type(json_core) :: json
        type(json_value),pointer :: p,pitems,pitem,pval,pbit

        call json%get(parent,'RigSize',p)

        call json%get(p,"RigType",pitem)
		call json%get(pitem,data%Configuration%RigSize%RigType)
        call json%get(p,"CrownHeight",pitem)
		call json%get(pitem,data%Configuration%RigSize%CrownHeight)
        call json%get(p,"MonkeyBoandHeight",pitem)
		call json%get(pitem,data%Configuration%RigSize%MonkeyBoandHeight)
        call json%get(p,"RigFloorHeight",pitem)
		call json%get(pitem,data%Configuration%RigSize%RigFloorHeight)

    end subroutine

end module CRigSize