System.JSON.Readers.TJsonReader.MaxDepth
Delphi
property MaxDepth: Integer read FMaxDepth write SetMaxDepth;
C++
__property int MaxDepth = {read=FMaxDepth, write=SetMaxDepth, nodefault};
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
property | public | System.JSON.Readers.pas System.JSON.Readers.hpp |
System.JSON.Readers | TJsonReader |
Description
Gets or sets the maximum Depth of nested level allowed when reading JSON.
Reading past the MaxDepth limit, raises a EJsonReaderException exception.
The <reader_name>'s MaxDeepth of <MaxDepth_value> has been exceeded. Path <path_to_token>, line <line_number>, position <position_number_inside_line>.
A negative value for MaxDepth means that there is no Depth limit. The default value is -1
.
For example:
'{"Transaction":['
'{"id":662713, "firstName":"John", "lastName":"Doe", "price": 2.1, "parent_id": null, validated:true, "items":[{"id":001,"ItemName":"Cup"},{"id":002,"ItemName":"Sticker"}]},'
'{"id":662714, "firstName":"Anna", "lastName":"Smith", "price": 4.5, "parent_id": null, validated: false},'
'{"id":662715, "firstName":"Peter", "lastName":"Jones", "price": 3.6, "parent_id": null, validated: true}'
']}'
If you set MaxDepth to 3
, the reader raises an exception when it arrives to items
:
The reader's MaxDeepth of 3 has been exceeded. Path Transaction[0].items, line 2, position 112.