module CReservoir
    use SimulationVariables
    use json_module
    implicit none

    contains    
    
    subroutine ReservoirToJson(parent)

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

        ! 1. create new node
        call json%create_object(p,'Reservoir')
        
        ! 2. add member of data type to new node
        ! call StringConfigurationToJson(p)
        ! call FormationToJson(p)
        call json%add(p,"AutoMigrationRate",data%Configuration%Reservoir%AutoMigrationRate)
        call json%add(p,"FluidGradient",data%Configuration%Reservoir%FluidGradient)
        call json%add(p,"FluidType",data%Configuration%Reservoir%FluidType)
        call json%add(p,"FluidViscosity",data%Configuration%Reservoir%FluidViscosity)
        call json%add(p,"FormationNo",data%Configuration%Reservoir%FormationNo)
        call json%add(p,"FormationPermeability",data%Configuration%Reservoir%FormationPermeability)
        call json%add(p,"FormationTop",data%Configuration%Reservoir%FormationTop)
        call json%add(p,"GeothermalGradient",data%Configuration%Reservoir%GeothermalGradient)
        call json%add(p,"InactiveInflux",data%Configuration%Reservoir%InactiveInflux)
        call json%add(p,"IsAutoMigrationRateSelected",data%Configuration%Reservoir%IsAutoMigrationRateSelected)
        call json%add(p,"MakeKickSinglePacket",data%Configuration%Reservoir%MakeKickSinglePacket)
        call json%add(p,"PressureGradient",data%Configuration%Reservoir%PressureGradient)

        ! 3. add new node to parent
        call json%add(parent,p)
    end subroutine
end module CReservoir