Libraries.Data.Formats.JavaScriptObjectNotation Documentation

This class can read in JavaScriptObjectNotation (JSON) formatted data from text values or from disk. When it reads them in, the data is stored inside this object. Alternatively, this class allows the programmer to set a listener object that can receive information about how the JSON file is being parsed as it occurs.

Example Code

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
action Main
     text dq = ""
     dq = dq:GetDoubleQuote()
     text myValue = "{" + dq + "data" + dq + ": [21.5, 22.7, 23.9]}"
     JavaScriptObjectNotation json
     json:Read(myValue)
     output json:ToText()
     output json:GetValue("data")
     i = 0
     repeat while i < json:GetSize()
         JavaScriptObjectNotation array = json:Get(i)
         if array:GetKey() = "data"
             j = 0
             repeat while j < array:GetSize()
                 JavaScriptObjectNotation item = array:Get(j)
                 output item:GetNumber()
                 j = j + 1
             end
         end
         i = i + 1
     end
end
end

Inherits from: Libraries.Language.Object

Actions Documentation

Add(Libraries.Data.Formats.JavaScriptObjectNotation object)

Use this method to add a nested JavaScriptObjectNotation object. The object must already have a key set.

Parameters

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation data
        data:Add("item1", "a")
        data:Add("item2", "b")
        data:Add("item3", "c")
        data:SetKey("detail")

        JavaScriptObjectNotation json
        json:Add("data1", "A")
        json:Add("data2", "B")
        json:Add(data)

        output json:ToText()
   end
end

Add(text key, text value)

Use this method to add a text item to a JavaScriptObjectNotation object.

Parameters

  • text key: The key value to add.
  • text value: The text value to add.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", "First Name")
        json:Add("item2", "Last Name")
        output json:ToText()
   end
end

Add(text key, integer value)

Use this method to add an integer item to a JavaScriptObjectNotation object.

Parameters

  • text key: The key value to add.
  • integer value: The integer value to add.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2)
        output json:ToText()
   end
end

Add(boolean value)

Use this method to add a boolean item to a JavaScriptObjectNotation array object.

Parameters

  • boolean value: The boolean value to add.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:SetKey("myArray")
        json:SetArray()
        json:Add(true)
        json:Add(true)
        json:Add(false)
        output json:ToText()
   end
end

Add(text key, boolean value)

Use this method to add a boolean item to a JavaScriptObjectNotation object.

Parameters

  • text key: The key value to add.
  • boolean value: The boolean value to add.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", true)
        json:Add("item2", false)
        output json:ToText()
   end
end

Add(number value)

Use this method to add a number item to a JavaScriptObjectNotation array object.

Parameters

  • number value: The number value to add.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:SetKey("myArray")
        json:SetArray()
        json:Add(1.1)
        json:Add(2.1)
        json:Add(3.1)
        output json:ToText()
   end
end

Add(text key, number value)

Use this method to add a number item to a JavaScriptObjectNotation object.

Parameters

  • text key: The key value to add.
  • number value: The number value to add.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1.1)
        json:Add("item2", 2.2)
        output json:ToText()
   end
end

Add(integer value)

Use this method to add a integer item to a JavaScriptObjectNotation array object.

Parameters

  • integer value: The integer value to add.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:SetKey("myArray")
        json:SetArray()
        json:Add(1)
        json:Add(2)
        json:Add(3)
        output json:ToText()
   end
end

Add(text key, Libraries.Data.Formats.JavaScriptObjectNotation object)

Use this method to add a nested JavaScriptObjectNotation object with a key. If the object you pass as a parameter already has a key, it will be nested inside the new key.

Parameters

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation data
        data:Add("item1", "a")
        data:Add("item2", "b")
        data:Add("item3", "c")

        JavaScriptObjectNotation json
        json:Add("data1", "A")
        json:Add("data2", "B")
        json:Add("detail", data)

        output json:ToText()
   end
end

Add(text value)

Use this method to add a text item to a JavaScriptObjectNotation array object.

Parameters

  • text value: The text value to add.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:SetKey("myArray")
        json:SetArray()
        json:Add("one")
        json:Add("two")
        json:Add("three")
        output json:ToText()
   end
end

Compare(Libraries.Language.Object object)

This action compares two object hash codes and returns an integer. The result is larger if this hash code is larger than the object passed as a parameter, smaller, or equal. In this case, -1 means smaller, 0 means equal, and 1 means larger. This action was changed in Quorum 7 to return an integer, instead of a CompareResult object, because the previous implementation was causing efficiency issues.

Parameters

Return

integer: The Compare result, Smaller, Equal, or Larger.

Example

Object o
Object t
integer result = o:Compare(t) //1 (larger), 0 (equal), or -1 (smaller)

Equals(Libraries.Language.Object object)

This action determines if two objects are equal based on their hash code values.

Parameters

Return

boolean: True if the hash codes are equal and false if they are not equal.

Example

use Libraries.Language.Object
use Libraries.Language.Types.Text
Object o
Text t
boolean result = o:Equals(t)

Get(integer index)

Use this method to return one of the items in the json object by it's index number

Parameters

  • integer index: The index value of the JavaScriptObjectNotation object.

Return

Libraries.Data.Formats.JavaScriptObjectNotation: The JavaScriptObjectNotation object at the specified index.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", true)
        json:Add("item2", 5)

        JavaScriptObjectNotation item = json:Get(0)
        if item:GetBoolean() = true
            output "Item 1 was true"
        else
            output "Item 1 was false"
        end
   end
end

GetArray()

This action returns the array from an array object. If this object is not an array object, this throws an error.

Return

Libraries.Data.Formats.JavaScriptObjectNotation: an array object. This throws an error if this is not an array object.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:SetObject()
        json:SetKey("Item")
    
        JavaScriptObjectNotation array
        array:SetArray()
        array:Add(1)
        array:Add(2)
    
        json:Add(array)
        json:SetArrayObject(true)

        //in this case, val = array
        JavaScriptObjectNotation val = json:GetArray()
        output val:ToText()
    end
end

GetBoolean(text key)

This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object.

Parameters

  • text key

Return

boolean: The value of the object as text.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("key1", 1)
        json:Add("key2", 2.2)
        json:Add("key3", "three")
        json:Add("key4", true)
        JavaScriptObjectNotation nested
        nested:SetKey("key5")
        nested:Add("item1", 1)
        nested:Add("item2", 2)
        nested:Add("item3", 3)
        json:Add(nested)

        output json:GetBoolean("key4")
    end
end

GetBoolean()

Use this method to get the boolean value of a JavaScriptObjectNotation object

Return

boolean: The boolean value of the object if applicable.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", true)

        JavaScriptObjectNotation item = json:Get(0)
        output item:GetBoolean()
   end
end

GetHashCode()

This action gets the hash code for an object.

Return

integer: The integer hash code of the object.

Example

Object o
integer hash = o:GetHashCode()

GetInteger()

This method returns an integer value of a JavaScriptObjectNotation object containing an integer type

Return

integer: The integer value of the object if applicable.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2)
        json:Add("item3", 3)

        sum = 0
        i = 0
        repeat json:GetSize() times
            sum = sum + json:Get(i):GetInteger()
            i = i + 1
        end
        output sum
   end
end

GetInteger(text key)

This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object.

Parameters

  • text key

Return

integer: The value of the object as text.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("key1", 1)
        json:Add("key2", 2.2)
        json:Add("key3", "three")
        json:Add("key4", true)
        JavaScriptObjectNotation nested
        nested:SetKey("key5")
        nested:Add("item1", 1)
        nested:Add("item2", 2)
        nested:Add("item3", 3)
        json:Add(nested)

        output json:GetInteger("key1")
    end
end

GetIterator()

Return

Libraries.Containers.Iterator: An iterator of the JavaScriptObjectNotation objects in the object.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation
use Libraries.Containers.Iterator

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1.1)
        json:Add("item2", 2.2)
        json:Add("item3", 3.3)

        number sum = 0
        i = 0
        Iterator<JavaScriptObjectNotation> myIterator = json:GetIterator()

        repeat while myIterator:HasNext()
            JavaScriptObjectNotation nextItem = myIterator:Next()
            sum = sum + nextItem:GetNumber()
            i = i + 1
        end
        output sum
   end
end

GetKey()

Use this method to get the key (or name) of a JavaScriptObjectNotation object

Return

text: The name of the JavaScriptObjectNotation object.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", true)

        JavaScriptObjectNotation item = json:Get(0)
        output item:GetKey()
   end
end

GetKeys()

This method returns an array of the key names inside a JavaScriptObjectNotation object

Return

Libraries.Containers.Array: An array of key values in the object.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation
use Libraries.Containers.Array

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2)
        json:Add("item3", 3)

        Array<text> keys = json:GetKeys()
        i = 0
        repeat keys:GetSize() times
            key = keys:Get(i)
            output key + " => " + json:GetValue(key)
            i = i + 1
        end
   end
end

GetNumber(text key)

This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object.

Parameters

  • text key

Return

number: The value of the object as text.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("key1", 1)
        json:Add("key2", 2.2)
        json:Add("key3", "three")
        json:Add("key4", true)
        JavaScriptObjectNotation nested
        nested:SetKey("key5")
        nested:Add("item1", 1)
        nested:Add("item2", 2)
        nested:Add("item3", 3)
        json:Add(nested)

        output json:GetNumber("key2")
    end
end

GetNumber()

This method returns a number value of a JavaScriptObjectNotation object containing a number type

Return

number: The number value of the object if applicable.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1.1)
        json:Add("item2", 2.2)
        json:Add("item3", 3.3)

        number sum = 0
        i = 0
        repeat json:GetSize() times
            sum = sum + json:Get(i):GetNumber()
            i = i + 1
        end
        output sum
   end
end

GetObject(text key)

This method returns the value of a JavaScriptObjectNotation object by the key name as a JavaScriptObjectNotation object.

Parameters

  • text key

Return

Libraries.Data.Formats.JavaScriptObjectNotation: The value of the object as text.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("key1", 1)
        json:Add("key2", 2.2)
        json:Add("key3", "three")
        json:Add("key4", true)
        JavaScriptObjectNotation nested
        nested:SetKey("key5")
        nested:Add("item1", 1)
        nested:Add("item2", 2)
        nested:Add("item3", 3)
        json:Add(nested)

        output json:GetObject("key5"):GetInteger("item1")
    end
end

GetSize()

This method returns a number of children in a JavaScriptObjectNotation object.

Return

integer: The number of children in the object.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1.1)
        json:Add("item2", 2.2)
        json:Add("item3", 3.3)

        output json:GetSize()
   end
end

GetText()

This method returns a text value of a JavaScriptObjectNotation object containing a text type

Return

text: The text value of the object if applicable.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", "one")
        json:Add("item2", "two")
        json:Add("item3", "three")

        i = 0
        repeat json:GetSize() times
            output json:Get(i):GetText()
            i = i + 1
        end
   end
end

GetType()

This method returns a type of a JavaScriptObjectNotation object as an integer code according to the following table: INTEGER = 1 NUMBER = 2 TEXT = 3 BOOLEAN = 4 UNDEFINED = 5 ARRAY = 6 OBJECT = 7 PARENT = 8

Return

integer: The type of the object as an integer.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", "one")
        json:Add("item2", 1)
        json:Add("item3", 1.1)
        json:Add("item4", true)

        i = 0
        repeat json:GetSize() times
            output json:Get(i):GetType()
            i = i + 1
        end
   end
end

GetTypeAsText()

This method returns a type of a JavaScriptObjectNotation object as text

Return

text: The type of the object as text.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", "one")
        json:Add("item2", 1)
        json:Add("item3", 1.1)
        json:Add("item4", true)

        i = 0
        repeat json:GetSize() times
            output json:Get(i):GetTypeAsText()
            i = i + 1
        end
   end
end

GetValue(text key)

This method returns the value of a JavaScriptObjectNotation object by the key name in text format

Parameters

  • text key: The key of the object to return

Return

text: The value of the object with the specified key.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")

        output json:GetValue("item1")
        output json:GetValue("item2")
        output json:GetValue("item3")
   end
end

GetValue()

This method returns the value of a JavaScriptObjectNotation object by the key name in text format

Return

text: The value of the object as text.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")

        output json:GetValue("item1")
        output json:GetValue("item2")
        output json:GetValue("item3")
   end
end

HasValue(text key)

This method returns whether or not there is an attribute at that key.

Parameters

  • text key: The key of the object to return

Return

boolean: The value of the object with the specified key.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")

        output json:HasValue("item1")
        output json:HasValue("item2")
        output json:HasValue("item7") //false
   end
end

IsArray()

This method returns true if a JavaScriptObjectNotation object is an array or false otherwise.

Return

boolean: A boolean value based on whether or not the object is an array.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")

        i = 0
        repeat json:GetSize() times
            output json:Get(i):IsArray()
            i = i + 1
        end
   end
end

IsArrayItem()

This item is used internally by the parser to check if an object as an array item.

Return

boolean: A boolean value to indicate if the object is an array item.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:IsArrayItem()
   end
end

IsArrayObject()

This action returns whether a JavaScriptObjectNotation object is a parent object of an array. An object can be an ArrayObject, one which contains an array, and in this case one must be an object. However, one can be an object, but not an array object. This would be the case if we were storing primitive values in an object. This flag must be set if the object contains an array.

Return

boolean: A boolean value based on whether or not the object is an array in disguise

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:SetObject()
        json:SetKey("Item")
    
        JavaScriptObjectNotation array
        array:SetArray()
        array:Add(1)
        array:Add(2)
    
        json:Add(array)
        json:SetArrayObject(true)
        output json:IsArrayObject()
    end
end

IsBoolean()

This method returns true if a JavaScriptObjectNotation object is a boolean value or false otherwise.

Return

boolean: A boolean value based on whether or not the object is a boolean type.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", true)
        json:Add("item3", "three")

        i = 0
        repeat json:GetSize() times
            output json:Get(i):IsBoolean()
            i = i + 1
        end
   end
end

IsEmpty()

This method returns true if a JavaScriptObjectNotation object contains values or false otherwise

Return

boolean: A boolean value based on whether or not the object is empty.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        output json:IsEmpty()
        json:Add("item1", 1)
        output json:IsEmpty()
   end
end

IsInteger()

This method returns true if a JavaScriptObjectNotation object is an integer value or false otherwise.

Return

boolean: A boolean value based on whether or not the object is an integer.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", true)
        json:Add("item3", "three")

        i = 0
        repeat json:GetSize() times
            output json:Get(i):IsInteger()
            i = i + 1
        end
   end
end

IsNumber()

This method returns true if a JavaScriptObjectNotation object is an integer value or false otherwise.

Return

boolean: A boolean value based on whether or not the object is a number.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")

        i = 0
        repeat json:GetSize() times
            output json:Get(i):IsNumber()
            i = i + 1
        end
   end
end

IsObject()

This method returns true if a JavaScriptObjectNotation object is an object or false otherwise.

Return

boolean: A boolean value based on whether or not the object is an object type.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")

        i = 0
        repeat json:GetSize() times
            output json:Get(i):IsObject()
            i = i + 1
        end
   end
end

IsParent()

This method returns true if a JavaScriptObjectNotation object is the parent or false otherwise.

Return

boolean: A boolean value based on whether or not the object is the parent.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")

        i = 0
        repeat json:GetSize() times
            output json:Get(i):IsObject()
            i = i + 1
        end
   end
end

IsPrettyPrint()

This method returns true if a JavaScriptObjectNotation object is set to format the output.

Return

boolean: A boolean value based on whether or not the object is set for formatted printing.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")

        output json:IsPrettyPrint()
   end
end

IsText()

This method returns true if a JavaScriptObjectNotation object is a text or false otherwise.

Return

boolean: A boolean value based on whether or not the object is a text type.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")

        i = 0
        repeat json:GetSize() times
            output json:Get(i):IsText()
            i = i + 1
        end
   end
end

IsUndefined()

This method returns true if a JavaScriptObjectNotation object is a text or false otherwise.

Return

boolean: A boolean value based on whether or not the object type is undefined.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")

        i = 0
        repeat json:GetSize() times
            output json:Get(i):IsUndefined()
            i = i + 1
        end
   end
end

Read(Libraries.Containers.HashTable<text:text> data)

This method will read a hash table to a JavaScriptObjectNotation object.

Parameters

Example

use Libraries.Data.Formats.JavaScriptObjectNotation
use Libraries.Containers.HashTable

class Main
    action Main
    JavaScriptObjectNotation json
    HashTable<text, text> table
    table:Add("1", "one")
    table:Add("2", "two ")
    table:Add("3", "three")
    json:Read(table)
    output json:ToText()
   end
end

Read(text data)

This method will read a text value to a JavaScriptObjectNotation object.

Parameters

  • text data: The text value to read into the object.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
    text dq = ""
    dq = dq:GetDoubleQuote()
    text myValue = "{" + dq + "item1" + dq + ": 1," + dq + "item2" + dq + ": 2}"
    JavaScriptObjectNotation json
    json:Read(myValue)
    output json:ToText()
   end
end

Read(Libraries.System.File file)

This method will read in the contents of a file to a JavaScriptObjectNotation object.

Parameters

Example

use Libraries.Data.Formats.JavaScriptObjectNotation
use Libraries.System.File

class Main
    action Main
        JavaScriptObjectNotation json
        File myFile
        myFile:SetPath("response.json")
        json:Read(myFile)
        output json:ToText()
   end
end

Remove(integer index)

This method removes an item from a JavaScriptObjectNotation object.

Parameters

  • integer index: The index of the child object to remove.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")
        json:Remove(1)
        output json:ToText()
   end
end

SetArray()

This method sets a JavaScriptObjectNotation object to array type

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:SetArray()
   end
end

SetArrayItem(boolean value)

This item is used internally by the parser to designate an object as an array item.

Parameters

  • boolean value: A boolean value to indicate if the object is an array item.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
   action Main
        JavaScriptObjectNotation json
        json:SetArrayItem(true)
   end
end

SetArrayObject(boolean arrayObject)

This action tells a JavaScriptObjectNotation object that it is a parent object of an array. An object can be an ArrayObject, one which contains an array, and in this case one must be an object. However, one can be an object, but not an array object. This would be the case if we were storing primitive values in an object. This flag must be set if the object contains an array.

Parameters

  • boolean arrayObject: A boolean value based on whether or not the object is an array in disguise

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:SetObject()
        json:SetKey("Item")
    
        JavaScriptObjectNotation array
        array:SetArray()
        array:Add(1)
        array:Add(2)
    
        json:Add(array)
        json:SetArrayObject(true)
        output json:ToText()
    end
end

SetBoolean(boolean value)

This method sets a JavaScriptObjectNotation object to boolean type with a specified value

Parameters

  • boolean value: The value to set in the object.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")
        json:Get(1):SetBoolean(false)
        output json:ToText()
   end
end

SetInteger(integer value)

This method sets a JavaScriptObjectNotation object to integer type with a specified value

Parameters

  • integer value: The value to set in the object.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")
        json:Get(1):SetBoolean(false)
        output json:ToText()
   end
end

SetKey(text key)

This method sets the name of a key of a JavaScriptObjectNotation object

Parameters

  • text key: The name of the object to set.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")
        json:Get(1):SetKey("number2")
        output json:ToText()
   end
end

SetNumber(number value)

This method sets a JavaScriptObjectNotation object to number type with a specified value

Parameters

  • number value: The value to set in the object.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")
        json:Get(1):SetNumber(10.0)
        output json:ToText()
   end
end

SetObject()

This method sets a JavaScriptObjectNotation object to object type

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:SetObject()
   end
end

SetParent()

This method sets a JavaScriptObjectNotation object to parent type

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:SetParent()
   end
end

SetPrettyPrint(boolean print)

This method sets a JavaScriptObjectNotation object to parent type

Parameters

  • boolean print: The boolean value to set formatted printing mode.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:SetPrettyPrint(true)
   end
end

SetText(text value)

This method sets a JavaScriptObjectNotation object to text type with a specified value

Parameters

  • text value: The text value of the object to set.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")
        json:Get(1):SetText("two")
        output json:ToText()
   end
end

SetUndefined()

This method sets a JavaScriptObjectNotation object to undefined type

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:SetUndefined()
   end
end

ToText()

This method prints a JavaScriptObjectNotation object in text format

Return

text: The text value of the object in JavaScriptObjectNotation format.

Example

use Libraries.Data.Formats.JavaScriptObjectNotation

class Main
    action Main
        JavaScriptObjectNotation json
        json:Add("item1", 1)
        json:Add("item2", 2.2)
        json:Add("item3", "three")
        json:Get(1):SetText("two")
        output json:ToText()
   end
end