function fix(a, b) {
      /* istanbul ignore if : too hard to create a test case for it */
      if (!a || !b) {
        return a;
      }

      for (let k in b) { // eslint-disable-line
        if (b.hasOwnProperty(k)) {
          /* istanbul ignore if : too hard to create a test case for it */
          if (is.plainObject(b[k])) {
            a[k] = is.plainObject(a[k]) ? fix(a[k], b[k]) : b[k];
          } else if (is.string(b[k]) && /^[0-9]+$/.test(b[k])) {
            // convert string into a number
            a[k] = to.number(b[k]);
          } else if (is.string(b[k]) && b[k][0] === '{') {
            // convert string into an object
            a[k] = fix({}, to.object(b[k]));
          } else {
            a[k] = b[k];
          }
        }
      }

      return a;
    }
function fix(a, b) {
      
      if (!a || !b) {
        return a;
      }

      for (let k in b) { 
        if (b.hasOwnProperty(k)) {
          
          if (is.plainObject(b[k])) {
            a[k] = is.plainObject(a[k]) ? fix(a[k], b[k]) : b[k];
          } else if (is.string(b[k]) && /^[0-9]+$/.test(b[k])) {
            
            a[k] = to.number(b[k]);
          } else if (is.string(b[k]) && b[k][0] === '{') {
            
            a[k] = fix({}, to.object(b[k]));
          } else {
            a[k] = b[k];
          }
        }
      }

      return a;
    }
function fix ( a , b ) { /* istanbul ignore if : too hard to create a test case for it */ if ( ! a || ! b ) { return a ; } for ( let k in b ) { // eslint-disable-line if ( b . hasOwnProperty ( k ) ) { /* istanbul ignore if : too hard to create a test case for it */ if ( is . plainObject ( b [ k ] ) ) { a [ k ] = is . plainObject ( a [ k ] ) ? fix ( a [ k ] , b [ k ] ) : b [ k ] ; } else if ( is . string ( b [ k ] ) && / ^[0-9]+$ / . test ( b [ k ] ) ) { // convert string into a number a [ k ] = to . number ( b [ k ] ) ; } else if ( is . string ( b [ k ] ) && b [ k ] [ 0 ] === '{' ) { // convert string into an object a [ k ] = fix ( { } , to . object ( b [ k ] ) ) ; } else { a [ k ] = b [ k ] ; } } } return a ; }
The following should be an object but the csv parser returns it as a string so this is used to fix that mistake `"{\"latitude\":-6.081689835,\"longitude\":145.3919983,\"level-2\":{\"level-3\":\"woohoo\"}}"` it also doesn't handle numbers correctly so this fixes those instances as well
The following should be an object but the csv parser returns it as a string so this is used to fix that mistake { \ latitude \ : - 6 . 081689835 \ longitude \ : 145 . 3919983 \ level - 2 \ : { \ level - 3 \ : \ woohoo \ }} it also doesn t handle numbers correctly so this fixes those instances as well