WebData Editor (Reference) provides an integrated environment for defining and editing
The built-in WebData Editor allows you to define the data structure for JSON, XML, HTML, and text content.
The Encoding drop-down menu is read-only on the WebData Editor. The definition of the data format must be made when creating the WebData object.
On this page:
Table of Contents | ||||
---|---|---|---|---|
|
In order to select other documents, or create new ones, the ComboBox and the Document Toolbar on top of the editor can be used.
data structures with dynamic tag binding. The WebData Editor enables:
Access via Reports → WebData Editor
Table of Contents maxLevel 2 minLevel 2 indent 10px exclude Steps style none
Embed tag values using curly brackets:
{Tag.TagName}
JSON:
json
{
"deviceId": "SENSOR-001",
"timestamp": "{Info.Date}",
"measurements": {
"temperature": {Tag.TankFarm/Tank1/Temp},
"pressure": {Tag.TankFarm/Tank1/Pressure},
"level": {Tag.TankFarm/Tank1/Level}
},
"status": "{Tag.Equipment/Status}"
}
XML:
xml
<SensorData>
<DeviceID>SENSOR-001</DeviceID>
<Timestamp>{Info.Date}</Timestamp>
<Temperature>{Tag.TankFarm/Tank1/Temp}</Temperature>
<Pressure>{Tag.TankFarm/Tank1/Pressure}</Pressure>
<Status>{Tag.Equipment/Status}</Status>
</SensorData>
HTML:
html
<html>
<body>
<h1>Production Report</h1>
<p>Date: {Info.Date}</p>
<p>Total Production: {Tag.Production_Count}</p>
<p>Quality Score: {Tag.Quality_Score}%</p>
</body>
</html>
Text:
Device Report
=============
Date: {Info.Date}
Temperature: {Tag.TankFarm/Tank1/Temp} °C
Pressure: {Tag.TankFarm/Tank1/Pressure} PSI
Status: {Tag.Equipment/Status}
Tags replace placeholders when sending:
json
// Template
{"name": "{Tag.UserName}"}
// If Tag.UserName = "John"
// Sent as:
{"name": "John"}
Tags populate from received content:
json
// WebData Template
{"temperature": "{Tag.Temp}"}
// Received Data
{"temperature": 25.5}
// Result: Tag.Temp = 25.5
When binding tags to nested JSON objects:
Template:
json
{
"data": "{Tag.SensorData}"
}
Received:
json
{
"data": {
"id": 175,
"values": [10, 20, 30],
"status": "active"
}
}
Result: Tag.SensorData receives entire nested object:
json
{
"id": 175,
"values": [10, 20, 30],
"status": "active"
}
json
{
// Use consistent indentation
"metadata": {
"version": "1.0",
"timestamp": "{Info.Date}"
},
// Group related data
"measurements": {
"temperature": {Tag.Temp},
"pressure": {Tag.Pressure}
},
// Handle arrays properly
"values": [
{Tag.Value1},
{Tag.Value2}
]
}
xml
<!-- Use proper nesting -->
<Root>
<!-- Group related elements -->
<Measurements>
<Temperature unit="C">{Tag.Temp}</Temperature>
<Pressure unit="PSI">{Tag.Pressure}</Pressure>
</Measurements>
<!-- Use attributes wisely -->
<Status code="{Tag.StatusCode}">{Tag.StatusText}</Status>
</Root>
json
{
"status": "{Tag.Status}",
"error": "{Tag.ErrorMessage}",
"retry": {Tag.RetryCount}
}
json
{
"method": "getData",
"params": {
"startDate": "{Tag.StartDate}",
"endDate": "{Tag.EndDate}",
"filters": {
"location": "{Tag.Location}",
"type": "{Tag.DataType}"
}
}
}
json
{
"settings": {
"interval": {Tag.UpdateInterval},
"threshold": {Tag.AlarmThreshold},
"enabled": {Tag.SystemEnabled}
}
}
xml
<StatusReport>
<Timestamp>{Info.Date} {Info.Time}</Timestamp>
<System>
<Running>{Tag.System_Running}</Running>
<Uptime>{Tag.System_Uptime}</Uptime>
</System>
<Production>
<Count>{Tag.Production_Count}</Count>
<Rate>{Tag.Production_Rate}</Rate>
</Production>
</StatusReport>
Tag not replacing:
Invalid JSON/XML:
Data not populating:
Performance issues:
Page Tree | ||
---|---|---|
|
When reading the file with the Data (or sending to a WebService), you replace parts of the text by Tags. To do that, surround the tag name with curly brackets.
Eg.: Replace "Name" : "John Robinson" by "Name" : "{Tag.MyTagWithTheName}"
The value of Tag.MyTagWithTheName will be used when reading the file or data package.
When loading files from disk, or receiving data packages from WebServices, the operation is reversed. If Tags are used, they will be populated with contents after parsing the contents of the received data.
In case of populating tags with received data contents, when using tags in JSON properties that contain another internal JSON, the content of the JSON, including all its properties, will be assigned to the tag.
Eg.:
WebData Editor Content:
Code Block |
---|
{
"slip": "{Tag.Advices}"
} |
Received Data:
Code Block |
---|
{
"slip": {
"id": 175,
"advice": "Plant a tree."
}
} |
The tag "Advices" will receive the value:
Code Block |
---|
{
"id": 175,
"advice": "Plant a tree."
} |
Proper formatting of WebData documents helps ensure that tag binding works as expected and that queries execute correctly.
In this section: