I store a key-value, json-like data structure in one property of my Object type in my Ontology.
I want a Workshop application to read one value of this json and display it in a given widget (e.g. markdown widget) for editing.
What is my property is of type string.
How can I extract this value ?
Here is an example in Typescript v1
import { Function, OntologyEditFunction, Integer } from "@foundry/functions-api";
interface MyCustomType {
a: string;
b: Integer;
}
export class MyFunctions {
@Function()
public myFunctionReturnStruct(): MyCustomType {
// TODO: read from the ontology Object you need
// TODO: Read the string property containing the json
// TODO: Parse json into datastructure of your choice
return {"a": "test", "b": 42};
}
You can then in Workshop create a variable of type “struct” which is populated via the function
You can then create a variable from the struct
You can then re-serialize the other way by passing the different variables as input of a function, that will serialize it in a json-string. You can then use Action to edit an Ontology object with this string.