import { isObject , keysOf } from "../utilities" ; import { fromJSONValueHelper } from "./fromJSONValueHelper" ; export const adjustTypesFromJSONValue = ( obj ) => { if ( obj === null ) { return null ; } const maybeChanged = fromJSONValueHelper ( obj ) ; if ( maybeChanged !== obj ) { return maybeChanged ; } if ( ! isObject ( obj ) ) { return obj ; } keysOf ( obj ) . forEach ( ( key ) => { const value = obj [ key ] ; if ( isObject ( value ) ) { const changed = fromJSONValueHelper ( value ) ; if ( value !== changed ) { obj [ key ] = changed ; return ; } adjustTypesFromJSONValue ( value ) ; } } ) ; return obj ; } ;