common ParseValue method for api or sql modes