parseJsonNumber

fnbool parseJsonNumber(const(char)[] lexeme, out var result, out string errorMsg, bool preferSigned = true) @safe

Parse a JSON number literal and return the appropriate var type.

This function takes a number lexeme and parses it into the most appropriate numeric type according to JSON semantics:

  • If the number is integral and fits in a long, use var.Type.LONG.
  • If the number is integral, non-negative, and fits in ulong but not long, use var.Type.ULONG.
  • Otherwise (decimals, exponents, overflow), use var.Type.DOUBLE.

Parameters

lexemeThe number literal lexeme from the lexer.
resultOutput parameter for the parsed value.
errorMsgOutput parameter for error message on failure.
preferSignedWhen true, prefer signed integers when value fits both.

Returns

true on success, false on error (with errorMsg set).