B2Win Suite Documentation (Under Construction)
5.4
5.4
  • B2Win Suite Documentation
  • Scripting
    • B2Win Suite Scripting Overview
    • Scripting in B2Data
      • Custom Script Nodes
        • Custom Script
        • Source Script Node (File)
        • Source Script Node (Table)
        • Source Script Node (Object)
        • If-Else Condition
        • Condition Node
      • In DataPrep
      • Properties
      • Workflow Applications
        • Workflow #1
        • Workflow #2
    • Getting Started
    • Language Basics
    • Types & Objects
      • Primitives
      • Objects
        • Instant
        • LocalDateTime
        • LocalDate
        • LocalTime
        • JsonNode
        • ObjectNode
        • File
        • SuiteTable
        • Duration
      • Arrays & Maps
      • Row, Column, StringColumn
    • Utilities
      • Date & Time
        • InstantUtil
        • GeneralDateUtil
        • LocalDateTimeUtil
        • LocalDateUtil
        • LocalTimeUtil
        • Formatting
        • Timezones
      • Math
      • StrictMath
      • NumericUtil
      • DbUtil
      • DbExecutor
      • StateUtil
      • FileUtil
      • JsonUtil
      • HttpUtil
      • NodeInputReader
      • RandomUtil
      • HashingUtil
      • CompressionUtil
      • Logging
    • Properties
    • Context and System
      • Context
      • System
    • Configurations
      • Workflow Configuration
    • Tutorial
    • Feedback
  • B2Data
    • Workflow Settings
      • General Settings
      • Global/All Properties
      • Execution Configuration
        • General
        • Runtime
        • Compiler
        • Storage
        • Clean Up
      • Permissions
    • Nodes
      • Scheduler
    • Services Configuration
      • Power BI
Powered by GitBook
On this page
  • Methods
  • Examples
  1. Scripting
  2. Types & Objects
  3. Objects

ObjectNode

Extends JsonNode

The JsonObject class represents a JSON object node and provides methods for manipulating its data.

Methods

  • get(key: String): JsonNode

Retrieves the value of the specified property from the JSON object.


  • put(key: String, intValue: Integer): void

Adds or replaces a property with an integer value.


  • put(key: String, longValue: Long): void

Adds or replaces a property with a long value.


  • put(key: String, floatValue: Float): void

Adds or replaces a property with a float value.


  • put(key: String, doubleValue: Float): void

Adds or replaces a property with a double value.


  • put(key: String, textValue: String): void

Adds or replaces a property with a text value.


  • put(key: String, value: JsonNode): void

Adds or replaces a property with a JsonNode value.


  • get(key: String): JsonNode

Retrieves a property value, as JsonNode.


  • remove(key: String): void

Removes a property.


  • has(key: String): Boolean

Checks if a property exists.


  • size(): Integer

Retrieves the number of properties.


  • clear(): void

Removes all properties.


  • isEmpty(): Boolean

Checks if the object node is empty.


  • toString(): String

Returns the JSON node as a JSON string.

Examples

var objectNode = JsonUtil.createObjectNode();

// Add properties to the JSON object
objectNode.put("name", "John Doe");
objectNode.put("age", 30);
objectNode.put("isStudent", true);
objectNode.put("scores", 6.2);

// Retrieve a property value
var name = objectNode.get("name").toString();
var age = objectNode.get("age").asInt();
var isStudent = objectNode.get("isStudent").asBoolean();
var scores = objectNode.get("scores");

// Remove a property
objectNode.remove("age");

// Check if a property exists
var hasAge = objectNode.has("age");

// Get the number of properties
var numProperties = objectNode.size();

// Clear all properties
objectNode.clear();

// Check if the object is empty
var isEmpty = objectNode.isEmpty();

// Get the JSON representation
var jsonString = objectNode.toString();
PreviousJsonNodeNextFile

Last updated 1 year ago