JsonStore Module

From OpenSimulator

Revision as of 16:25, 17 April 2012 by Cmickeyb (Talk | contribs)

Jump to: navigation, search

Contents

Introduction

The JsonStore module enables scripts and region modules to share structured data among themselves.

Enabling the Module

Add the following to your OpenSim.ini to enable the JsonStore module: 

[JsonStore]
Enabled = True

JsonStore Path Syntax

JsonStore Value Syntax

JsonStore Script Functions

  • JsonCreateStore
  • JsonDestroyStore
  • JsonReadNotecard
  • JsonWriteNotecard
  • JsonTestPath/JsonTestPathJson
  • JsonGetValue/JsonGetValueJson
  • JsonTakeValue/JsonTakeValueJson
  • JsonReadValue/JsonReadValueJson
  • JsonSetValue/JsonSetValueJson

key storeID = JsonCreateStore(string jsonvalue)

Create a JsonStore and initialize it using the Json encoded value. The new store identifier is returned.

integer status = JsonDestroyStore(key storeID)

Destroy the JsonStore associated with the provided identifier. Return 1 if the operation is successful.

key requestID = JsonReadNotecard(key storeID, string path, key assetID)

Request that the Json encoded content of a notecard be decoded and  placed in the structure in the store at the given path. The function returns the request identifier. When the operation completes, a link_message event is generated with the request identifier.

key requestID = JsonWriteNotecard(key storeID, string path, string notecard)

Request that the value identified by the given path be Json encoded and written to the notecard. The function returns the request identifier. When the operation completes, a link_message event is generated with the request identifier.

int status = JsonTestPath(key storeID, string path)
int status = JsonTestPathJson(key storeID, string path)

Check to see if there is a value identified by the path. In the case of JsonTestPath() the value must be a string. In the case of JsonTestPathJson() the value can be a string, an array, or a dictionary. The function returns 1 when there is an appropriate value.

string value = JsonGetValue(key storeID, string path)
string jsonvalue = JsonGetValueJson(key storeID, string path)

Return the value identified by the path. In the case of JsonGetValue() the value must be a string. In the case of JsonGetValueJson() the value will be Json encoded string, array or dictionary.

key requestID = JsonTakeValue(key storeID, string path)
key reqeustID = JsonTakeValueJson(key storeID, string path)

Request that the value identified by the path be removed from the store and returned to the script when it is available. The value will be returned through a link_message event with the requestID. JsonTakeValue() will request a string value. JsonTakeValueJson() will request a Json encoded string that corresponds to a string, array or hash value.

This function is used to wait for a value to be available and then return. Since the operation of read and remove is atomic, it can be used to implement locks, task queues and other synchronization primitives.

key requestID = JsonReadValue(key storeID, string path)
key reqeustID = JsonReadValueJson(key storeID, string path)

Request that the value identified by the path be returned to the script when it is available. The value will be returned through a link_message event with the requestID. JsonReadValue() will request a string value. JsonReadValueJson() will request a Json encoded string that corresponds to a string, array or hash value.

Unlike the JsonTakeValue() operation, the JsonReadValue operation does not remove the value from the store once it becomes available.

int status = JsonSetValue(key storeID, string path, string value)
int status = JsonSetValue(key storeID, string path, string jsonvalue)

Save the value at the location identified by the path in the store. Any value currently at the location will be replaced. JsonSetValue() assumes that the value is a string. JsonSetValueJson() assumes that the value is a Json encoded string.

int status = JsonRemoveValue(key storeID, string path)

Remove from the store the value identified by the path.

Examples

Personal tools
General
About This Wiki