/// Parse a JSON string
/// @access public
/// @param {String} $json - JSON string to parse
/// @throw Input string may not be null.
/// @return {*}
/// @require {function} _json-decode--value
@function json-decode($json) {
  $length: str-length($json);
  $pointer: 1;
  $value: null;

  @if $json == null {
    @return _throw("Input string may not be null.", $pointer);
  }

  @while $value != false // Stop if error
  and $pointer <= $length {
    $read: _json-decode--value($json, $pointer);
    $pointer: nth($read, 1);
    $value: nth($read, 2);
  }

  @return $value;
}
