parser.js
function (token, value) {
  var self = this;
  var emitString = false;
  function additionalEmit(additionalKey, additionalValue) {
    var oldKey = self.internalParser.key;
    self.internalParser.key = additionalKey;
    self.internalParser.onValue(additionalValue);
    self.internalParser.key = oldKey;
  }

  if (token === JsonParser.C.STRING ||
  token === JsonParser.C.NUMBER ||
  token === JsonParser.C.TRUE ||
  token === JsonParser.C.FALSE ||
  token === JsonParser.C.NULL) {
    // Parser will emit value in these cases
    if (typeof value === 'number' && 
    this.internalParser.string.indexOf('.') != -1 && 
    parseInt(this.internalParser.string) === value &&
    this.internalParser.mode !== JsonParser.C.ARRAY) {
      var typeKey = this.internalParser.key + '@odata.type';
      if (this.internalParser.value) {
        this.internalParser.value[typeKey] = 'Edm.Double';
      }
      additionalEmit(typeKey, 'Edm.Double');
      
      // Determine whether return raw string to avoid losing precision
      emitString = this.internalParser.string !== value.toString();
    }
  }
  if (emitString) {
    this.originalOnToken.call(this.internalParser, token, this.internalParser.string);
  } else {
    this.originalOnToken.call(this.internalParser, token, value);
  }
}
function (token, value) {
  var self = this;
  var emitString = false;
  function additionalEmit(additionalKey, additionalValue) {
    var oldKey = self.internalParser.key;
    self.internalParser.key = additionalKey;
    self.internalParser.onValue(additionalValue);
    self.internalParser.key = oldKey;
  }

  if (token === JsonParser.C.STRING ||
  token === JsonParser.C.NUMBER ||
  token === JsonParser.C.TRUE ||
  token === JsonParser.C.FALSE ||
  token === JsonParser.C.NULL) {
    // Parser will emit value in these cases
    if (typeof value === 'number' && 
    this.internalParser.string.indexOf('.') != -1 && 
    parseInt(this.internalParser.string) === value &&
    this.internalParser.mode !== JsonParser.C.ARRAY) {
      var typeKey = this.internalParser.key + '@odata.type';
      if (this.internalParser.value) {
        this.internalParser.value[typeKey] = 'Edm.Double';
      }
      additionalEmit(typeKey, 'Edm.Double');
      
      // Determine whether return raw string to avoid losing precision
      emitString = this.internalParser.string !== value.toString();
    }
  }
  if (emitString) {
    this.originalOnToken.call(this.internalParser, token, this.internalParser.string);
  } else {
    this.originalOnToken.call(this.internalParser, token, value);
  }
}
function ( token , value ) { var self = this ; var emitString = false ; function additionalEmit ( additionalKey , additionalValue ) { var oldKey = self . internalParser . key ; self . internalParser . key = additionalKey ; self . internalParser . onValue ( additionalValue ) ; self . internalParser . key = oldKey ; } if ( token === JsonParser . C . STRING || token === JsonParser . C . NUMBER || token === JsonParser . C . TRUE || token === JsonParser . C . FALSE || token === JsonParser . C . NULL ) { // Parser will emit value in these cases if ( typeof value === 'number' && this . internalParser . string . indexOf ( '.' ) != - 1 && parseInt ( this . internalParser . string ) === value && this . internalParser . mode !== JsonParser . C . ARRAY ) { var typeKey = this . internalParser . key + '@odata.type' ; if ( this . internalParser . value ) { this . internalParser . value [ typeKey ] = 'Edm.Double' ; } additionalEmit ( typeKey , 'Edm.Double' ) ; // Determine whether return raw string to avoid losing precision emitString = this . internalParser . string !== value . toString ( ) ; } } if ( emitString ) { this . originalOnToken . call ( this . internalParser , token , this . internalParser . string ) ; } else { this . originalOnToken . call ( this . internalParser , token , value ) ; } }
Handles the EDM types in the JSON object
1. Number will be treated as Edm.Int32 by default
2. Literal value 1.0 will be treated as Edm.Double
3. Others will be handled according to the literal value
Handles the EDM types in the JSON object 1 . Number will be treated as Edm . Int32 by default 2 . Literal value 1 . 0 will be treated as Edm . Double 3 . Others will be handled according to the literal value