JSON ==== JSON parsing. ----- TJSONParser.Construct --------------------- ``` function TJSONArray.Construct: TJSONArray; static; function TJSONObject.Construct: TJSONObject; static; function TJSONParser.Construct: TJSONParser; static; ``` Constructors for JSON. Use the `new` keyword for these. ``` var parser: TJSONParser; begin parser := new TJSONParser(); parser.Parse('{"someNumber": 123, someString: "hello"}'); WriteLn parser.Typ; WriteLn parser.Count; WriteLn parser.Item[0].Typ; WriteLn parser.Item[0].AsInt; WriteLn parser.Item['someString'].Typ; WriteLn parser.Item['someString'].AsString; end; ``` ----- TJSONParser.Parse ----------------- ``` procedure TJSONParser.Parse(Str: String); ``` Parse a json string. ----- TJSONParser.Load ---------------- ``` procedure TJSONParser.Load(FileName: String); ``` Parse json from a file. ----- TJSONParser.Save ---------------- ``` procedure TJSONParser.Save(FileName: String; Options: EJSONFormatOptions = []; Indent: Integer = 2); ``` Formats the json parser to a string and saves to file. ----- TJSONItem.Typ ------------- ``` property TJSONItem.Typ: EJSONType ``` Returns json type of the item. This can be any of: - `EJSONType.UNKNOWN` - `EJSONType.INT` - `EJSONType.FLOAT` - `EJSONType.STR` - `EJSONType.BOOL` - `EJSONType.NULL` - `EJSONType.ARR` - `EJSONType.OBJ` ----- TJSONItem.Format ---------------- ``` function TJSONItem.Format(Options: EJSONFormatOptions = []; Indent: Integer = 2): String; ``` Formats the json item into a JSON string. Options can be a set of: - `EJSONFormatOption.SINGLE_LINE_ARR`: Array without CR/LF : all on one line - `EJSONFormatOption.SINGLE_LINE_OBJ`: Object without CR/LF : all on one line - `EJSONFormatOption.NO_QUOTE_MEMBERS`: Do not quote object member names. - `EJSONFormatOption.USE_TABS`: Use tab characters instead of spaces. - `EJSONFormatOption.NO_WHITESPACE`: Do not use whitespace at all