Source/NFX/CodeAnalysis/JSON/JSONNumbers.cs
/// <summary>
/// Tries to convert string to number, returns null if conversion could not be made
/// </summary>
Tries to convert string to number, returns null if conversion could not be made
Tries to convert string to number returns null if conversion could not be made
public static object Convert(string str, out JSONTokenType type)
    {
      ulong inum = 0;
      double fnum = 0.0;
      if (strToInt(str, out inum))
      {
        if (inum > UInt32.MaxValue)
        {
          type = JSONTokenType.tLongIntLiteral;
        }
        else
        {
          type = JSONTokenType.tIntLiteral;
          if (inum<Int32.MaxValue)
           return (Int32)inum;
        }
        return inum;
      }
      if (strToFloat(str, out fnum))
      {
        type = JSONTokenType.tDoubleLiteral;
        return fnum;
      }
      type = JSONTokenType.tUnknown;
      return null;
    }
public static object Convert ( string str , out JSONTokenType type ) { ulong inum = 0 ; double fnum = 0.0 ; if ( strToInt ( str , out inum ) ) { if ( inum > UInt32 . MaxValue ) { type = JSONTokenType . tLongIntLiteral ; } else { type = JSONTokenType . tIntLiteral ; if ( inum < Int32 . MaxValue ) return ( Int32 ) inum ; } return inum ; } if ( strToFloat ( str , out fnum ) ) { type = JSONTokenType . tDoubleLiteral ; return fnum ; } type = JSONTokenType . tUnknown ; return null ; }
Tries to convert string to number, returns null if conversion could not be made
Tries to convert string to number returns null if conversion could not be made
str
string
JSONTokenType
out