The JsonRpcService object provides mechanisms for exposing user-defined functions via JSON-RPC. Additionally arbitrary user-defined properties inside this object can be read and written via getProperty() and setProperty().





This property holds the name of the JSON-RPC service user for registering to the JSON-RPC server. It is prepended to all method names, i.e. foo() can be called through the JSON-RPC method <serviceName>.foo.

This property was introduced in InCore 2.5.

› Type:String
› Default:incore
› Signal:serviceNameChanged()
› Attributes:Writable


getProperty(Variant name)

This method can be called remotely and returns the property specified by name if it exists.

› Returns:Variant

setProperty(Variant name, Variant value)

This method can be called remotely and sets the property specified by name to the given value.

› Returns:Variant


import InCore.Foundation 2.5

Application {

    JsonRpcClient {
        id: rpcClient
        onErrorCodeReceived: console.log("Call to", name, "returned with error code", errorCode)
        onErrorMessageReceived: console.log("Call to", name, "returned with error message", errorMessage)

    onCompleted:  {
        rpcClient.getProperty("systemClock", (value) => { console.log("System clock:", value) })
        rpcClient.call("callMe", ["My message"], (retval) => { console.log("callMe() returned:", retval)})
        rpcClient.call("nonExistingFunction", [])

    MeasurementGroup {
        id: myMeasurements
        Measurement { id: meas1; data: Math.random() }
        Measurement { id: meas2; data: Math.random() }
        Measurement { id: meas3; data: Math.random() }

    System {
        id: system

    JsonRpcServer {
        JsonRpcService {
            // calling getProperty("myMeasurements") via JSON-RPC will return JSON-serialized representation
            // of the MeasurementGroup
            readonly property alias measurements: myMeasurements

            // allow to read and write the system clock via JSON-RPC e.g. by calling
            // setProperty("systemClock", 1569241016)
            property alias systemClock: system.clock

            function callMe(message)
                console.log("I have a message for you:", message)
                return [ "Hello", "world" ]