# JsonObject.Add(Text, Text) Method
> Version: _Available or changed with runtime version 1.0._
Adds a new property to a JsonObject.
## Syntax
```al
[Ok := ]  JsonObject.Add(Key: Text, Value: Text)
```
## Parameters
JsonObject
Type: jsonobject-data-type
An instance of the jsonobject-data-type data type.
Key
Type: ../text/text-data-type
Value
Type: ../text/text-data-type
## Return Value
*[Optional] Ok*
Type: ../boolean/boolean-data-type
true if the operation was successful; otherwise false. If you omit this optional return value and the operation does not execute successfully, a runtime error will occur.
## Remarks
The operation will fail if the object already contains a property with the given key.
Note that text constants, such as labels or raw text values assigned in the source code, will be transformed by the compiler. All characters that require escaping in C# strings will be prefixed with the backslash symbol ('\\'). These characters include single and double quotes, backslashes, control characters (for example, line feed or tab). For more information, refer to https://learn.microsoft.com/dotnet/csharp/programming-guide/strings/#string-escape-sequences.
## Example 1
In this example, the newline symbol '\n' is changed to '\\\\n' when the value is added to the JSON object.
```al
local procedure AddMultilineTextValue()
var
    TextValue: Label 'Multiline\nValue';
    JObj: JsonObject;
begin
    JObj.Add('Key', TextValue);
end;
```
When the code above is run, the variable JObj has the following value.
```
{
    "Key": "Multiline\\nValue"
}
```
## Example 2
One way to avoid redundant escaping is to use the JsonToken.ReadFrom(Text) method<../jsontoken/jsontoken-readfrom-string-method>
In the following example, the text value is assigned to a JsonToken variable, which is then appended to a JsonObject.
Note the double quotes in the TextValue label.
```al
local procedure AddMultilineTextValue()
var
    TextValue: Label '"Multiline\nValue"';
    JTok: JsonToken;
    JObj: JsonObject;
begin
    JTok.ReadFrom(TextValue);
    JObj.Add('Key', JTok);
end;
```
The value of the variable JObj after running the code of this example is as follows.
```
{
    "Key": "Multiline\nValue"
}
```
## Example 3
Another method is to add unescaped control characters to the AL text.
```al
local procedure AddMultilineTextValue()
var
    Builder: TextBuilder;
    JObj: JsonObject;
begin
    Builder.AppendLine('Multiline');
    Builder.Append('Value');
    JObj.Add('Key', Builder.ToText());
end;
```
In the example above, TextBuilder.AppendLine method adds unescaped characters `0x0D` and `0x0A` at the end of the line, so the resulting JsonObject contains the escaped `\r` `\n` values.
```
{
    "Key": "Multiline\r\nValue"
}
```
## Related information
jsonobject-data-type
Get Started with AL<../../devenv-get-started>
Developing Extensions<../../devenv-dev-overview>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/jsonobject/jsonobject-add-string-string-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/jsonobject/jsonobject-add-string-string-method/
