4D v14.3OB SET |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
4D v14.3
OB SET
|
OB SET ( object ; property ; value {; property2 ; value2 ; ... ; propertyN ; valueN} ) | ||||||||
Parameter | Type | Description | ||||||
object | Object |
![]() |
Structured object | |||||
property | Text |
![]() |
Name of property to set | |||||
value | Text, Date, Boolean, Pointer, Number, Object |
![]() |
New value of property | |||||
The OB SET command creates or modifies one or more property/value pairs in the language object designated by the object parameter.
object must have been defined using the C_OBJECT command.
In the property parameter, pass the label of the property to be created or modified. If the property already exists in object, its value is updated. If it does not exist, it is created.
Note that the property parameter is case sensitive.
In the value parameter, pass the value you want to set for the property. Several data types are supported. Note that:
Creating an object and adding a text type property:
C_OBJECT($Object)
OB SET($Object ;"FirstName";"John";"LastName";"Smith")
// $Object = {"FirstName":"John","LastName":"Smith"}
Creating an object and adding a Boolean type property:
Modifying a property:
// $Object = {"FirstName":"John","LastName":"Smith"}
OB SET($Object ;"FirstName";"Paul")
// $Object = {"FirstName":"Paul","LastName":"Smith"}
Adding a property:
// $Object = {"FirstName":"John","LastName":"Smith"}
OB SET($Object ;"department";"Accounting")
// $Object = {"FirstName":"Paul","LastName":"Smith","department":"Accounting"}
Renaming a property:
Using a pointer:
// $Object = {"FirstName":"Paul","LastName":"Smith"}
C_TEXT($LastName)
OB SET($Object ;"LastName";->$LastName)
// $Object = {"FirstName":"Paul","LastName":"->$LastName"}
$JsonString:=JSON Stringify($Object)
// $JsonString="{"FirstName":"Paul","LastName":""}
$LastName:="Wesson"
$JsonString:=JSON Stringify($Object)
// $JsonString="{"FirstName":"Paul","LastName":"Wesson"}
Using an object:
C_OBJECT($ref_smith)
OB SET($ref_smith ;"name";"Smith")
C_OBJECT($ref_emp)
OB SET($ref_emp ;"employee";$ref_smith)
$Json_string :=JSON Stringify($ref_emp)
// $ref_emp = {"employee":{"name":"Smith"}} (object)
// $Json_string = "{"employee":{"name":"Smith"}}" (string)
You can also change a value on the fly:
OB SET($ref_smith ;"name";"Smyth")
// $ref_smith = {"employee":{"name":"Smyth"}}
$string:=JSON Stringify($ref_emp)
// $string = "{"employee":{"name":"Smyth"}}"
Using an object array:
C_TEXT($jsonString)
C_OBJECT($Contact)
OB SET($Contact;"FirstName";"Alan")
OB SET($Contact;"LastName";"Monroe")
OB SET($Contact;"age";40)
OB SET($Contact;"telephone";"[2128675309,2128671234]")
$jsonString:=JSON Stringify($Contact)
// Value of $Contact:
// {"LastName":"Monroe","telephone":"[2128675309,2128671234]",
// "age":40,"FirstName":"Alan"}
// Value of $jsonString:
// "{"LastName":"Monroe","telephone":"[2128675309,2128671234]",
// "age":40,"FirstName":"Alan"}"
Product: 4D
Theme: Objects (Language)
Number:
1220
Created: 4D v14
OB REMOVE
OB SET ARRAY
OB SET NULL
4D Language Reference ( 4D v14 R2)
4D Language Reference ( 4D v14 R3)
4D Language Reference ( 4D v14.3)
4D Language Reference ( 4D v14 R4)