JSON parsing
normalizeJsonSyntax
Converts a string that resembles JSON but with numeric keys and single-quoted values into valid JSON format. This function replaces numeric keys with quoted numeric keys and ensures all values are double-quoted as required by JSON.The input string that needs to be fixed into valid JSON
string - A valid JSON string.
isJsonStructureValid
Checks if a given string resembles a JSON object with numeric or quoted keys and values that are single or double quoted. This is useful for detecting malformed JSON-like structures that can be fixed by thenormalizeJsonSyntax function.
The input string to check
boolean - Returns true if the string is JSON-like, false otherwise.
Quote and bracket validation
isBalanced
Checks if both quotes and brackets are balanced in a string. This function combines quote balance checking and bracket balance checking to ensure the entire string has properly balanced punctuation. A string is considered balanced when:- All double quotes have matching pairs (even count)
- All brackets (parentheses, square brackets, curly braces) are properly matched and nested
The string to check for balanced quotes and brackets
boolean - True if both quotes and brackets are balanced, false otherwise.
String splitting
splitByQuotes
Splits a string by spaces and quoted substrings. This function takes an input string and splits it into parts where substrings enclosed in double quotes are treated as a single part. Other substrings separated by spaces are split normally.The input string to be split
string[] - An array of strings, with quoted substrings kept intact.
Page and range parsing
parsePageRanges
Parses page input string into array of page numbers, supporting ranges and lists.Page specification string (e.g., “1-5” or “1,3,5”)
number[] - Array of page numbers.
Throws: Error when start page exceeds end page in range.
Time conversion
timeToSeconds
Converts a time string to seconds.Time string in “HH:MM:SS”, “MM:SS”, or number format
number - Total seconds as a number.