Extract nested values from Javascript objects and arrays