module CBopStack
    use SimulationVariables
    use json_module
    implicit none    
    public
    contains

    subroutine BopStackToJson(parent)

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

        ! 1. create new node
        call json%create_object(p,'BopStack')
        
        ! 2. add member of data type to new node
        call json%add(p,"AboveAnnularHeight",data%Configuration%BopStack%AboveAnnularHeight)
        call json%add(p,"AnnularPreventerClose",data%Configuration%BopStack%AnnularPreventerClose)
        call json%add(p,"AnnularPreventerHeight",data%Configuration%BopStack%AnnularPreventerHeight)
        call json%add(p,"AnnularPreventerOpen",data%Configuration%BopStack%AnnularPreventerOpen)
        call json%add(p,"AnnularStringDrag",data%Configuration%BopStack%AnnularStringDrag)
        call json%add(p,"BlindRamClose",data%Configuration%BopStack%BlindRamClose)
        call json%add(p,"BlindRamHeight",data%Configuration%BopStack%BlindRamHeight)
        call json%add(p,"BlindRamOpen",data%Configuration%BopStack%BlindRamOpen)
        call json%add(p,"ChokeClose",data%Configuration%BopStack%ChokeClose)
        call json%add(p,"ChokeLineId",data%Configuration%BopStack%ChokeLineId)
        call json%add(p,"ChokeLineLength",data%Configuration%BopStack%ChokeLineLength)
        call json%add(p,"ChokeOpen",data%Configuration%BopStack%ChokeOpen)
        call json%add(p,"GroundLevel",data%Configuration%BopStack%GroundLevel)
        call json%add(p,"KillClose",data%Configuration%BopStack%KillClose)
        call json%add(p,"KillHeight",data%Configuration%BopStack%KillHeight)
        call json%add(p,"KillOpen",data%Configuration%BopStack%KillOpen)
        call json%add(p,"LowerRamClose",data%Configuration%BopStack%LowerRamClose)
        call json%add(p,"LowerRamHeight",data%Configuration%BopStack%LowerRamHeight)
        call json%add(p,"LowerRamOpen",data%Configuration%BopStack%LowerRamOpen)
        call json%add(p,"RamStringDrag",data%Configuration%BopStack%RamStringDrag)
        call json%add(p,"UpperRamClose",data%Configuration%BopStack%UpperRamClose)
        call json%add(p,"UpperRamHeight",data%Configuration%BopStack%UpperRamHeight)
        call json%add(p,"UpperRamOpen",data%Configuration%BopStack%UpperRamOpen)
        ! 3. add new node to parent
        call json%add(parent,p)
    end subroutine

end module CBopStack