JNumber
Derived from
JValue
Class to store number value in JSON format. Once JNumber instance is created, its value can't be changed.
There is no limit how long or big numbers can be, but trying to read too big number for example as long will cause exception. Oversized numbers can be still read out and handled as strings.
Constructors
Methods
public byte AsByte () | Gets value of this number object as byte. | public decimal AsDecimal () | Gets value of this number object as decimal. | public double AsDouble () | Gets value of this number object as double. | public float AsFloat () | Gets value of this number object as float. | public int AsInt () | Gets value of this number object as int. | public long AsLong () | Gets value of this number object as long. | public object AsObject () | Gets value of this number as object. | public sbyte AsSByte () | Gets value of this number object as signed byte. | public short AsShort () | Gets value of this number object as short. | public string AsString () | Gets value of this number as string. | public uint AsUInt () | Gets value of this number object as unsigned int. | public ulong AsULong () | Gets value of this number object as unsigned long. | public ushort AsUShort () | Gets value of this number object as unsigned short. | public override bool Equals (object anotherObject) | Test if another object equals to this object. | public override string ToString () | Returns compact information of this JNumber object as string, for debug purposes. |
Constructors
public JNumber (string numberAsString) Creates new JSON number value from string. There is no limits in number size as long as it follows json number format. Parameters | numberAsString | Value for this JNumber object in string format. |
Exceptions | JArgumentException | If parameter string is not valid number. |
public JNumber (int numberAsInt) Creates new JSON number value from c# int value. Parameters | numberAsInt | Value for this JNumber object. |
public JNumber (long numberAsLong) Creates new JSON number value from c# long value. Parameters | numberAsLong | Value for this JNumber object. |
public JNumber (float numberAsFloat) Creates new JSON number value from c# float value. Parameters | numberAsFloat | Value for this JNumber object. |
Exceptions | JArgumentException | If parameter is NaN or Infinity. |
public JNumber (double numberAsDouble) Creates new JSON number value from c# double value. Parameters | numberAsDouble | Value for this JNumber object. |
Exceptions | JArgumentException | If parameter is NaN or Infinity. |
public JNumber (decimal numberAsDecimal) Creates new JSON number value from c# decimal value. Parameters | numberAsDecimal | Value for this JNumber object. |
Methods
public byte AsByte () Gets value of this number object as byte. This will throw exception if number is floating point number or outside byte range. Exceptions | JNumberFormatException | If number stored to this JNumber is floating point number. | | JNumberOverflowException | If number stored to this JNumber doesn't fit in byte. |
public decimal AsDecimal () Gets value of this number object as decimal. This will throw exception if number is outside decimal range or number contains E/e notation. Exceptions | JNumberFormatException | If number stored to this JNumber uses E/e notation (like 1.234567e89) | | JNumberOverflowException | If number stored to this JNumber doesn't fit in decimal. |
public double AsDouble () Gets value of this number object as double. This will throw exception if number is outside double range. Exceptions | JNumberOverflowException | If number stored to this JNumber doesn't fit in double. |
public float AsFloat () Gets value of this number object as float. This will throw exception if number is outside float range. Exceptions | JNumberOverflowException | If number stored to this JNumber doesn't fit in float. |
public int AsInt () Gets value of this number object as int. This will throw exception if number is floating point number or outside int range. Exceptions | JNumberFormatException | If number stored to this JNumber is floating point number. | | JNumberOverflowException | If number stored to this JNumber doesn't fit in int. |
public long AsLong () Gets value of this number object as long. This will throw exception if number is floating point number or outside long range. Exceptions | JNumberFormatException | If number stored to this JNumber is floating point number. | | JNumberOverflowException | If number stored to this JNumber doesn't fit in long. |
public object AsObject () Gets value of this number as object. First fitting value of these are returned: int, long, float, double Returns | Value as object, that may be one of the 4 basic number objects. |
Exceptions | JNumberOverflowException | If number stored to this JNumber doesn't fit in double. |
public sbyte AsSByte () Gets value of this number object as signed byte. This will throw exception if number is floating point number or outside sbyte range. Exceptions | JNumberFormatException | If number stored to this JNumber is floating point number. | | JNumberOverflowException | If number stored to this JNumber doesn't fit in sbyte. |
public short AsShort () Gets value of this number object as short. This will throw exception if number is floating point number or outside short range. Exceptions | JNumberFormatException | If number stored to this JNumber is floating point number. | | JNumberOverflowException | If number stored to this JNumber doesn't fit in short. |
public string AsString () Gets value of this number as string.
public uint AsUInt () Gets value of this number object as unsigned int. This will throw exception if number is floating point number or outside uint range. Exceptions | JNumberFormatException | If number stored to this JNumber is floating point number. | | JNumberOverflowException | If number stored to this JNumber doesn't fit in uint. |
public ulong AsULong () Gets value of this number object as unsigned long. This will throw exception if number is floating point number or outside ulong range. Exceptions | JNumberFormatException | If number stored to this JNumber is floating point number. | | JNumberOverflowException | If number stored to this JNumber doesn't fit in ulong. |
public ushort AsUShort () Gets value of this number object as unsigned short. This will throw exception if number is floating point number or outside ushort range. Exceptions | JNumberFormatException | If number stored to this JNumber is floating point number. | | JNumberOverflowException | If number stored to this JNumber doesn't fit in ushort. |
public override bool Equals (object anotherObject) Test if another object equals to this object. Always returns false if parameter object is null or it is not instance of JNumber. Two JNumber objects are equal if both contains value which string representation is exactly equal. For example JNumber that contains "1" is not equal to JNumber that contains "1.0" Parameters | anotherObject | Another object that is compared to this one. |
Returns | True if objects are equal, false otherwise. |
public override string ToString () Returns compact information of this JNumber object as string, for debug purposes. Returns | Single string with information of this JNumber object. |
|