π Fix Json SchemaΒΆ
operators.fix_json_schema
RecursiveReplace(
key="type",
map_values={
"dict": "object",
"float": "number",
"tuple": "array",
"HashMap": "object",
"bool": "boolean",
"list": "array",
"any": "string",
"int": "integer",
"byte": "integer",
"short": "integer",
"long": "integer",
"double": "number",
"char": "string",
"ArrayList": "array",
"Array": "array",
"Hashtable": "object",
"Queue": "array",
"Stack": "array",
"Any": "string",
"String": "string",
"str, optional": "string",
"str": "string",
"Bigint": "integer",
"Set": "array",
"Boolean": "boolean",
},
remove_values=[
"any",
],
)
[source]Explanation about RecursiveReplaceΒΆ
An operator to recursively replace values in dictionary fields of instances based on a key and a mapping of values.
- Attributes:
key (str): The key in the dictionary to start the replacement process. map_values (dict): A dictionary containing the key-value pairs to replace the original values. remove_values (Optional[list]): An optional list of values to remove from the dictionary. Defaults to None.
Example: RecursiveReplace(key=βaβ, map_values={β1β: βhiβ, β2β: βbyeβ }, remove_values=[β3β])
replaces the value of key βaβ in all instances of all streams: instance
{"field" : [{"a": "1", "b" : "2"}, {"a" : "3", "b:" "4"}}` becomes ``{"field" : [{"a": "hi", "b" : "2"}, {"b": "4"}}Notice how the value of field
"a"in the first instance is replaced with"hi"and the value of field"a"in the second instance is removed.
Read more about catalog usage here.