System.JSON.Writers.TJsonTextWriter.WritePropertyName
Delphi
procedure WritePropertyName(const Name: string); overload; override;
procedure WritePropertyName(const Name: string; Escape: Boolean); overload;
C++
virtual void __fastcall WritePropertyName(const System::UnicodeString Name)/* overload */;
HIDESBASE void __fastcall WritePropertyName(const System::UnicodeString Name, bool Escape)/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
procedure function |
public | System.JSON.Writers.pas System.JSON.Writers.hpp |
System.JSON.Writers | TJsonTextWriter |
Description
Writes the property name of a name/value pair on a JSON object.
Parameters:
Name
: The name of the property.Escape
: Replaces some special characters with their escape codes.True
to convert andFalse
for the opposite. It automatically escapes multibyte characters.
See the code snippet below to illustrate the use of WritePropertyName:
Writer.WriteStartObject;
Writer.WritePropertyName('colors');
Writer.WriteStartArray;
Writer.WriteStartObject;
Writer.WriteComment('Hexadecimal value for the red color');
Writer.WritePropertyName('name');
Writer.WriteValue('red');
Writer.WritePropertyName('hex');
Writer.WriteValue('#f00');
Writer.WriteEndObject;
Writer.WriteEndArray;
{
"colors": [
{
/*Hexadecimal value for the red color*/
"name": "red",
"hex": "#f00"
}
]
}