### Join Function Usage Examples Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/JoinFunction.html Demonstrates how to use the $join function to concatenate strings from an array. The first example shows joining without a separator, and the second shows joining with a specified separator after a split operation. ```jsonata $join(['a','b','c'])=="abc" ``` ```jsonata $split("too much, punctuation. hard; to read", /[" ",".",";"]+/, 3) ~> $join(', ')=="too, much, punctuation" ``` -------------------------------- ### PadFunction Examples Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/PadFunction.html Demonstrates various use cases of the $pad function, including right padding, left padding, and padding with a custom character. Also shows integration with $formatBase. ```jsonata $pad("foo", 5)=="foo " ``` ```jsonata $pad("foo", -5)==" foo" ``` ```jsonata $pad("foo", -5, "#") == "##foo" ``` ```jsonata $formatBase(35, 2) ~> $pad(-8, '0')=="00100011" ``` -------------------------------- ### Build JSONata4Java JARs with Maven Source: https://github.com/ibm/jsonata4java/blob/master/README.md Use Maven to clean and install the project, generating the necessary JAR files in the target directory. Ensure project dependencies are updated first. ```bash mvn clean install -Dgpg.skip ``` -------------------------------- ### Maven Build Configuration Source: https://github.com/ibm/jsonata4java/blob/master/.README.md.html Instructions for building the project using Maven. Ensure dependencies are updated before running a clean install. ```xml com.fasterxml.jackson.core jackson-databind 2.9.8 ``` -------------------------------- ### Build and Deploy JSONata4Java JARs to Maven Central Source: https://github.com/ibm/jsonata4java/blob/master/README.md Execute this command to build, install, and deploy the JARs to Maven Central. This requires release profile activation. ```bash mvn clean install deploy -Prelease ``` -------------------------------- ### JSON Data for Customer Mapping Source: https://github.com/ibm/jsonata4java/blob/master/README.md Example JSON data structure used for demonstrating function chaining with customer names. ```json { "Customer": [ " paul ", " berverly " ] } ``` -------------------------------- ### NowFunction Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/package-tree.html Gets the current date and time. ```APIDOC ## NowFunction ### Description Returns the current date and time in ISO 8601 format. ### Method Function Call ### Request Example ```jsonata NowFunction() ``` ### Response #### Success Response - **dateTime** (string) - The current date and time in ISO 8601 format. ``` -------------------------------- ### JSONata $random() Function Examples (Test) Source: https://github.com/ibm/jsonata4java/blob/master/docs/index-files/index-17.html Illustrates the $random() function within a testing context, showing expected outputs for pseudo-random number generation. ```jsonata $random()==0.7973541067127 ``` ```jsonata $random()==0.4029142127028 ``` ```jsonata $random()==0.6558078550072 ``` -------------------------------- ### Demonstrate JSONata4Java Date/Time Functions in Java Source: https://context7.com/ibm/jsonata4java/llms.txt This Java example illustrates the use of JSONata built-in date and time functions, including $millis, $fromMillis, $toMillis, $fromMillisZoned, and $now, for handling epoch milliseconds and ISO-8601 date strings. ```java import com.api.jsonata4java.expressions.Expressions; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.JsonNodeFactory; public class DateTimeFunctionsExample { public static void main(String[] args) throws Exception { JsonNode nil = JsonNodeFactory.instance.objectNode(); // $millis — current epoch ms (varies at runtime) JsonNode ms = Expressions.parse("$millis()").evaluate(nil); System.out.println(ms); // e.g. 1718000000000 // $fromMillis — epoch ms → ISO-8601 string JsonNode iso = Expressions.parse("$fromMillis(1510067557121)").evaluate(nil); System.out.println(iso); // "2017-11-07T15:12:37.121Z" // $toMillis — ISO-8601 string → epoch ms JsonNode epoch = Expressions.parse("$toMillis(\"2017-11-07T15:12:37.121Z\")").evaluate(nil); System.out.println(epoch); // 1510067557121 // $fromMillisZoned — with timezone (v2.4+) JsonNode localTime = Expressions.parse( "$fromMillisZoned(1510067557121, \"[Y]-[M01]-[D01]T[H01]:[m01]:[s01]\", \"America/New_York\")" ).evaluate(nil); System.out.println(localTime); // "2017-11-07T10:12:37" // $now — current ISO-8601 timestamp JsonNode now = Expressions.parse("$now()").evaluate(nil); System.out.println(now); // e.g. "2024-06-10T12:00:00.000Z" } } ``` -------------------------------- ### FormatNumberFunction Examples Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/FormatNumberFunction.html Demonstrates various ways to format numbers using the $formatNumber function with different picture strings and options. This function is consistent with XPath/XQuery's fn:format-number. ```jsonata $formatNumber(12345.6, '#,###.00')=="12,345.60" ``` ```jsonata $formatNumber(1234.5678, "00.000e0")=="12.346e2" ``` ```jsonata $formatNumber(34.555, "#0.00;(#0.00)")=="34.56" ``` ```jsonata $formatNumber(-34.555, "#0.00;(#0.00)")=="(34.56)" ``` ```jsonata $formatNumber(0.14, "01%")=="14%" ``` ```jsonata $formatNumber(0.14, "###pm", {"per-mille": "pm"})=="140pm" ``` ```jsonata $formatNumber(1234.5678, "①①.①①①e①", {"zero-digit": "⑟"})=="①②.③④⑥e②" ``` -------------------------------- ### ExprOrSeqListContext Constructors and Methods Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.ExprOrSeqListContext.html Details on the constructors and methods available for the ExprOrSeqListContext. ```APIDOC ## Class MappingExpressionParser.ExprOrSeqListContext ### Description Represents a context in the parser for an expression or sequence list. ### Constructor Summary * **ExprOrSeqListContext**(org.antlr.v4.runtime.ParserRuleContext parent, int invokingState) * Constructs a new ExprOrSeqListContext with the specified parent context and invoking state. ### Method Summary * **accept**(org.antlr.v4.runtime.tree.ParseTreeVisitor visitor) : T * Accepts a visitor for the parse tree. * **enterRule**(org.antlr.v4.runtime.tree.ParseTreeListener listener) : void * Enters the rule context for this parser rule. * **exitRule**(org.antlr.v4.runtime.tree.ParseTreeListener listener) : void * Exits the rule context for this parser rule. * **getExprOrSeqs**() : java.util.List * Returns a list of all ExprOrSeq contexts within this list. ``` -------------------------------- ### main Method Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/Sequence.html Entry point for the Sequence class, used for testing or execution. ```APIDOC ## main(String[] args) ### Description Entry point for the Sequence class, used for testing or execution. ### Method `main` ### Parameters #### Path Parameters - **args** (java.lang.String[]) - Command line arguments. ``` -------------------------------- ### MillisFunction Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/package-tree.html Gets the current time in milliseconds. ```APIDOC ## MillisFunction ### Description Returns the current time as the number of milliseconds since the Unix epoch. ### Method Function Call ### Request Example ```jsonata MillisFunction() ``` ### Response #### Success Response - **milliseconds** (number) - The current time in milliseconds. ``` -------------------------------- ### PathExpressionVisitor.main Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/path/PathExpressionVisitor.html Entry point for the PathExpressionVisitor class, used for command-line execution. ```APIDOC ## main ### Description Entry point for the PathExpressionVisitor class. ### Method public static void main(java.lang.String[] args) ### Parameters #### Path Parameters - **args** (java.lang.String[]) - command line arguments ``` -------------------------------- ### getRuleIndex() Method Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.ExprListContext.html Gets the rule index for this context. ```APIDOC ## getRuleIndex() ### Description Returns the rule index for this parser rule context. ### Overrides * `getRuleIndex` in class `org.antlr.v4.runtime.RuleContext` ### Returns * int - The rule index. ``` -------------------------------- ### NowFunction.invoke Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/class-use/ExpressionsVisitor.html Invokes the NowFunction to get the current timestamp. ```APIDOC ## NowFunction.invoke ### Description Invokes the NowFunction, which returns the current date and time. ### Method Signature `NowFunction.invoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx)` ### Parameters * `expressionVisitor` (ExpressionsVisitor) - The visitor pattern implementation for traversing the expression tree. * `ctx` (MappingExpressionParser.Function_callContext) - The context of the function call being evaluated. ### Returns `com.fasterxml.jackson.databind.JsonNode` - A JSON node representing the current timestamp. ``` -------------------------------- ### LogorContext Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.LogorContext.html Initializes a new instance of the LogorContext class. ```APIDOC ## LogorContext Constructor ### Description Initializes a new instance of the LogorContext class. ### Parameters * **ctx** (MappingExpressionParser.ExprContext) - The expression context to copy from. ``` -------------------------------- ### get(JsonNode, Integer) Source: https://github.com/ibm/jsonata4java/blob/master/docs/index-files/index-7.html Retrieves an element from a JsonNode at a specified index. ```APIDOC ## get(JsonNode, Integer) ### Description Retrieves an element from a JsonNode at a specified index. ### Method Method ### Class com.api.jsonata4java.expressions.path.PathExpression ``` -------------------------------- ### getValuesListExpressionOrNullNode Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/class-use/ExpressionsVisitor.html Gets the expression at the specified index from the context's ExprValuesContext. ```APIDOC ## getValuesListExpressionOrNullNode ### Description Gets the expression at the supplied index from the context's {link ExprValuesContext} {link ExprListContext]. ### Method Signature `static com.fasterxml.jackson.databind.JsonNode getValuesListExpressionOrNullNode(ExpressionsVisitor exprVisitor, MappingExpressionParser.Function_callContext ctx, int index)` ``` -------------------------------- ### prompt (String) Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/JSONataUtils.html Prints a prompt and returns the trimmed user response. ```APIDOC ## prompt (String) ### Description Print the supplied prompt (if not null) and return the trimmed response. ### Method Signature `static java.lang.String prompt(java.lang.String strPrompt)` ``` -------------------------------- ### SubstringFunction Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/package-tree.html Extracts a portion of a string based on start index and length. ```APIDOC ## SubstringFunction ### Description Extracts a substring from a given string based on a starting position and an optional length. ### Method N/A (This is a Java class) ### Parameters - **input** (string): The string to extract from. - **start** (integer): The starting index (0-based). - **length** (integer, optional): The number of characters to extract. If omitted, extracts to the end of the string. ### Request Example N/A ### Response - **output** (string): The extracted substring. ``` -------------------------------- ### MappingExpressionParser.ExprOrSeqContext Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/index-files/index-5.html Details the constructor for the `ExprOrSeqContext` class. ```APIDOC ## POST /api/jsonata4java/expressions/generated/MappingExpressionParser/ExprOrSeqContext ### Description Constructs a new `ExprOrSeqContext` instance. ### Method POST ### Endpoint /api/jsonata4java/expressions/generated/MappingExpressionParser/ExprOrSeqContext ### Parameters #### Request Body - **parserRuleContext** (org.antlr.v4.runtime.ParserRuleContext) - Required - The parent parser rule context. - **int** (int) - Required - An integer representing the rule index. ### Response #### Success Response (200) - **ExprOrSeqContext** (com.api.jsonata4java.expressions.generated.MappingExpressionParser.ExprOrSeqContext) - The newly created `ExprOrSeqContext` object. #### Response Example { "example": "ExprOrSeqContext object" } ``` -------------------------------- ### getSerializedATN Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/path/generated/PathExpressionLexer.html Gets the serialized form of the ATN (Abstract Syntax Tree) for the lexer. ```APIDOC ## getSerializedATN ### Description Gets the serialized form of the ATN (Abstract Syntax Tree) for the lexer. ### Method public java.lang.String getSerializedATN() ### Overrides `getSerializedATN` in class `org.antlr.v4.runtime.Recognizer` ``` -------------------------------- ### main Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/JSONataUtils.html The main entry point for the JSONataUtils class. This method can be used to run the utility class from the command line, typically for testing or demonstration purposes. ```APIDOC ## main ### Description Entry point for the JSONataUtils class. Executes the main functionality, often used for command-line execution or testing. ### Method Signature public static void main(String[] args) ### Throws * **java.lang.Exception** - If an error occurs during execution. ``` -------------------------------- ### expr() - Get all expressions Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.LogandContext.html Retrieves a list of all expression contexts within this LogandContext. ```APIDOC ## expr() ### Description Retrieves a list of all expression contexts associated with this LogandContext. ### Returns * `java.util.List` - A list of expression contexts. ``` -------------------------------- ### getRuleIndex() Source: https://github.com/ibm/jsonata4java/blob/master/docs/index-files/index-7.html Method to get the rule index. Available in various contexts within MappingExpressionParser. ```APIDOC ## getRuleIndex() ### Description Retrieves the rule index for the specific context. ### Method Method ### Class com.api.jsonata4java.expressions.generated.MappingExpressionParser.EmptyValuesContext com.api.jsonata4java.expressions.generated.MappingExpressionParser.ExprContext com.api.jsonata4java.expressions.generated.MappingExpressionParser.ExprListContext com.api.jsonata4java.expressions.generated.MappingExpressionParser.ExprOrSeqContext com.api.jsonata4java.expressions.generated.MappingExpressionParser.ExprOrSeqListContext com.api.jsonata4java.expressions.generated.MappingExpressionParser.ExprValuesContext com.api.jsonata4java.expressions.generated.MappingExpressionParser.FieldListContext ``` -------------------------------- ### main Method Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/SumFunction.html Entry point for the SumFunction class, typically used for testing or standalone execution. ```APIDOC ## main ### Description Provides a static entry point for the SumFunction, often used for demonstration or testing purposes. ### Method public static void main(java.lang.String[] args) ``` -------------------------------- ### expr() - Get all expressions Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.LogorContext.html Retrieves a list of all expression contexts associated with this logical OR operation. ```APIDOC ## expr() ### Description Retrieves a list of all expression contexts associated with this logical OR operation. ### Returns * `java.util.List` - A list of expression contexts. ``` -------------------------------- ### expr() - Get all expressions Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.MembershipContext.html Retrieves a list of all expression contexts associated with this membership context. ```APIDOC ## expr() ### Description Returns a list of all `ExprContext` objects within this `MembershipContext`. ### Returns * `java.util.List` - A list of expression contexts. ``` -------------------------------- ### accept Method Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.NullContext.html Accepts a visitor to process this context. ```APIDOC ## accept Method ### Description Accepts a `ParseTreeVisitor` to visit this node. ### Parameters * **visitor** (`ParseTreeVisitor`) - The visitor to accept. ### Returns * **T** - The result of the visitor's visit. ``` -------------------------------- ### expr(int i) - Get specific expression Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.LogandContext.html Retrieves a specific expression context by its index. ```APIDOC ## expr(int i) ### Description Retrieves a specific expression context from the list by its index. ### Parameters * **i** (int) - The index of the desired expression context. ### Returns * `MappingExpressionParser.ExprContext` - The expression context at the specified index. ``` -------------------------------- ### MappingExpressionParser.ExprOrSeqListContext Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/index-files/index-5.html Details the constructor for the `ExprOrSeqListContext` class. ```APIDOC ## POST /api/jsonata4java/expressions/generated/MappingExpressionParser/ExprOrSeqListContext ### Description Constructs a new `ExprOrSeqListContext` instance. ### Method POST ### Endpoint /api/jsonata4java/expressions/generated/MappingExpressionParser/ExprOrSeqListContext ### Parameters #### Request Body - **parserRuleContext** (org.antlr.v4.runtime.ParserRuleContext) - Required - The parent parser rule context. - **int** (int) - Required - An integer representing the rule index. ### Response #### Success Response (200) - **ExprOrSeqListContext** (com.api.jsonata4java.expressions.generated.MappingExpressionParser.ExprOrSeqListContext) - The newly created `ExprOrSeqListContext` object. #### Response Example { "example": "ExprOrSeqListContext object" } ``` -------------------------------- ### $substring(str, start [, length]) Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/class-use/Function.html Complies with javascript substr (and thus JSONata $substring). ```APIDOC ## $substring(str, start [, length]) ### Description Extracts a substring from a string. Complies with javascript substr (and thus JSONata $substring). ### Parameters * **str** (string) - The string to extract from. * **start** (number) - The starting index of the substring. * **length** (number, optional) - The length of the substring to extract. ``` -------------------------------- ### MappingExpressionParser.Array_constructorContext Methods Source: https://github.com/ibm/jsonata4java/blob/master/docs/index-files/index-5.html Details the `exprOrSeqList` method within the `MappingExpressionParser.Array_constructorContext` class. ```APIDOC ## GET /api/jsonata4java/expressions/generated/MappingExpressionParser/Array_constructorContext/exprOrSeqList ### Description Retrieves a list of expressions or sequences within an array constructor. ### Method GET ### Endpoint /api/jsonata4java/expressions/generated/MappingExpressionParser/Array_constructorContext/exprOrSeqList ### Response #### Success Response (200) - **ExprOrSeqListContext** (com.api.jsonata4java.expressions.generated.MappingExpressionParser.ExprOrSeqListContext) - Description of the returned expression or sequence list context. #### Response Example { "example": "ExprOrSeqListContext object" } ``` -------------------------------- ### getRuleIndex Method Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.FieldListContext.html Gets the rule index for this parser rule context. Overrides the method from RuleContext. ```APIDOC public int getRuleIndex() ``` -------------------------------- ### ExprOrSeqContext Methods Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.ExprOrSeqContext.html This section details the methods available on the ExprOrSeqContext object, including constructors and specific parser rule methods. ```APIDOC ## Constructor Detail ### ExprOrSeqContext ```java public ExprOrSeqContext(org.antlr.v4.runtime.ParserRuleContext parent, int invokingState) ``` ## Method Detail ### seq ```java public MappingExpressionParser.SeqContext seq() ``` ### expr ```java public MappingExpressionParser.ExprContext expr() ``` ### getRuleIndex ```java public int getRuleIndex() ``` Overrides: `getRuleIndex` in class `org.antlr.v4.runtime.RuleContext` ### enterRule ```java public void enterRule(org.antlr.v4.runtime.tree.ParseTreeListener listener) ``` Overrides: `enterRule` in class `org.antlr.v4.runtime.ParserRuleContext` ### exitRule ```java public void exitRule(org.antlr.v4.runtime.tree.ParseTreeListener listener) ``` Overrides: `exitRule` in class `org.antlr.v4.runtime.ParserRuleContext` ### accept ```java public T accept(org.antlr.v4.runtime.tree.ParseTreeVisitor visitor) ``` Specified by: `accept` in interface `org.antlr.v4.runtime.tree.ParseTree` Overrides: `accept` in class `org.antlr.v4.runtime.RuleContext` ``` -------------------------------- ### prompt (String, boolean) Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/JSONataUtils.html Prints a prompt and returns the user response, with optional trimming. ```APIDOC ## prompt (String, boolean) ### Description Print the supplied prompt (if not null) and return the trimmed response according to the supplied trim control. ### Method Signature `static java.lang.String prompt(java.lang.String strPrompt, boolean bTrim)` ``` -------------------------------- ### expr(int i) - Get specific expression context Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.ConditionalContext.html Retrieves a specific expression context by its index. ```APIDOC ## expr(int i) ### Description Returns the `ExprContext` at the specified index within this `ConditionalContext`. ### Parameters * **i** (`int`) - The index of the desired expression context. ### Returns * `MappingExpressionParser.ExprContext` - The expression context at the given index. ``` -------------------------------- ### enterExprOrSeqList Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionListener.html Enter a parse tree produced by MappingExpressionParser.exprOrSeqList(). ```APIDOC ## enterExprOrSeqList ### Description Enter a parse tree produced by `MappingExpressionParser.exprOrSeqList()`. ### Method Signature `void enterExprOrSeqList(MappingExpressionParser.ExprOrSeqListContext ctx)` ``` -------------------------------- ### expr() - Get all expression contexts Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.ConditionalContext.html Retrieves a list of all expression contexts associated with this conditional context. ```APIDOC ## expr() ### Description Returns a list of all `ExprContext` objects within this `ConditionalContext`. ### Returns * `java.util.List` - A list containing all expression contexts. ``` -------------------------------- ### accept Method Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.Sift_functionContext.html Accepts a ParseTreeVisitor to process this context. ```APIDOC ## accept Method ### Description Accepts a ParseTreeVisitor to process this context and return a result. ### Method Signature `public T accept(org.antlr.v4.runtime.tree.ParseTreeVisitor visitor)` ### Specified by `accept` in interface `org.antlr.v4.runtime.tree.ParseTree` ### Overrides `accept` in class `org.antlr.v4.runtime.RuleContext` ``` -------------------------------- ### NowFunction.invoke Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/class-use/MappingExpressionParser.Function_callContext.html Invokes the NowFunction to get the current date and time. It accepts an ExpressionsVisitor and a Function_callContext, returning a JsonNode. ```APIDOC ## NowFunction.invoke ### Description Invokes the NowFunction to get the current date and time. ### Method Signature `com.fasterxml.jackson.databind.JsonNode invoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx)` ``` -------------------------------- ### prompt Source: https://github.com/ibm/jsonata4java/blob/master/docs/index-files/index-16.html Prints the supplied prompt (if not null) and returns the trimmed response. ```APIDOC ## prompt ### Description Print the supplied prompt (if not null) and return the trimmed response. ### Method Signature `static String prompt(String prompt)` ### Class `com.api.jsonata4java.JSONataUtils` ``` -------------------------------- ### slice (without end) Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/utils/ArrayUtils.html Returns a shallow copy of the portion of the supplied array from the start index through the end of the array. ```APIDOC ## slice ### Description Returns a shallow copy of the portion of the supplied array from start through the end of the array. ### Method `public static com.fasterxml.jackson.databind.node.ArrayNode slice(com.fasterxml.jackson.databind.node.ArrayNode array, int start)` ### Parameters #### Path Parameters - **array** (com.fasterxml.jackson.databind.node.ArrayNode) - The input array to be sliced. - **start** (int) - The starting index where the slice should occur. ### Returns `com.fasterxml.jackson.databind.node.ArrayNode` - A shallow copy of the portion of the supplied array from start through the end of the array. ``` -------------------------------- ### accept Method Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.Var_recallContext.html Accepts a visitor to visit the node. ```APIDOC ## accept Method ### Description Accepts a visitor to visit the node. ### Specified by * `accept` in interface `org.antlr.v4.runtime.tree.ParseTree` ### Overrides * `accept` in class `org.antlr.v4.runtime.RuleContext` ### Parameters * **visitor** (org.antlr.v4.runtime.tree.ParseTreeVisitor) - The visitor to accept. ### Returns * T - The result of the visitor's visit. ``` -------------------------------- ### slice (with end) Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/utils/ArrayUtils.html Returns a shallow copy of the portion of the supplied array from the start index up to, but not including, the end index. ```APIDOC ## slice ### Description Returns a shallow copy of the portion of the supplied array from start to end (not including end). ### Method `public static com.fasterxml.jackson.databind.node.ArrayNode slice(com.fasterxml.jackson.databind.node.ArrayNode array, int start, int end)` ### Parameters #### Path Parameters - **array** (com.fasterxml.jackson.databind.node.ArrayNode) - The input array to be sliced. - **start** (int) - The starting index of the slice. - **end** (int) - The ending index of the slice (exclusive). ### Returns `com.fasterxml.jackson.databind.node.ArrayNode` - A shallow copy of the specified portion of the array. ``` -------------------------------- ### LogandContext Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.LogandContext.html Initializes a new instance of the LogandContext class. ```APIDOC ## LogandContext Constructor ### Description Initializes a new instance of the LogandContext class. ### Parameters * **ctx** (MappingExpressionParser.ExprContext) - The expression context to copy from. ``` -------------------------------- ### prompt Source: https://github.com/ibm/jsonata4java/blob/master/docs/index-files/index-16.html Prints the supplied prompt (if not null) and returns the trimmed response according to the supplied trim control. ```APIDOC ## prompt ### Description Print the supplied prompt (if not null) and return the trimmed response according to the supplied trim control. ### Method Signature `static String prompt(String prompt, boolean trim)` ### Class `com.api.jsonata4java.JSONataUtils` ``` -------------------------------- ### CeilFunction.invoke Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/class-use/ExpressionsVisitor.html Invokes the CeilFunction to get the ceiling value of a number in a mapping expression. It requires an ExpressionsVisitor and a Function_callContext, returning a JsonNode. ```APIDOC ## CeilFunction.invoke ### Description Invokes the CeilFunction to get the ceiling value of a number in a mapping expression. It requires an ExpressionsVisitor and a Function_callContext, returning a JsonNode. ### Method Signature `CeilFunction.invoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx)` ### Parameters - **expressionVisitor** (ExpressionsVisitor) - The visitor pattern implementation for expression traversal. - **ctx** (MappingExpressionParser.Function_callContext) - The context of the function call. ### Returns - `com.fasterxml.jackson.databind.JsonNode` - The result of the CeilFunction execution. ``` -------------------------------- ### Sequence Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/Sequence.html Initializes a new instance of the Sequence class. ```APIDOC ## Sequence() ### Description Initializes a new instance of the Sequence class. ### Constructor `Sequence()` ``` -------------------------------- ### FloorFunction.invoke Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/class-use/ExpressionsVisitor.html Invokes the FloorFunction to get the floor value of a JSON node. It takes an ExpressionsVisitor and a Function_callContext as input and returns a JsonNode. ```APIDOC ## FloorFunction.invoke ### Description Invokes the FloorFunction to get the floor value of a JSON node. ### Method Signature `invoke(ExpressionsVisitor expressionVisitor, MappingExpressionParser.Function_callContext ctx)` ### Parameters - **expressionVisitor** (ExpressionsVisitor) - The visitor pattern implementation for expressions. - **ctx** (MappingExpressionParser.Function_callContext) - The context of the function call. ### Returns `com.fasterxml.jackson.databind.JsonNode` - The floor value of the input. ``` -------------------------------- ### Percentage Formatting Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/test/expressions/FormatNumberFunctionTests.html Shows how to format a number as a percentage using a picture string. ```jsonata $formatNumber(0.14, "01%") == "14%" ``` -------------------------------- ### ExprOrSeqListContext Methods Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.ExprOrSeqListContext.html Provides access to the list of ExprOrSeqContext elements within this context. ```APIDOC ## ExprOrSeqListContext ### Description Represents a list of expression or sequence contexts. ### Methods #### exprOrSeq ```java public java.util.List exprOrSeq() ``` Returns a list of all `ExprOrSeqContext` children. #### exprOrSeq ```java public MappingExpressionParser.ExprOrSeqContext exprOrSeq(int i) ``` Returns the `ExprOrSeqContext` at the specified index. #### getRuleIndex ```java public int getRuleIndex() ``` Overrides `getRuleIndex` in `org.antlr.v4.runtime.RuleContext`. #### enterRule ```java public void enterRule(org.antlr.v4.runtime.tree.ParseTreeListener listener) ``` Overrides `enterRule` in `org.antlr.v4.runtime.ParserRuleContext`. #### exitRule ```java public void exitRule(org.antlr.v4.runtime.tree.ParseTreeListener listener) ``` Overrides `exitRule` in `org.antlr.v4.runtime.ParserRuleContext`. #### accept ```java public T accept(org.antlr.v4.runtime.tree.ParseTreeVisitor visitor) ``` Specified by `accept` in interface `org.antlr.v4.runtime.tree.ParseTree`. Overrides `accept` in class `org.antlr.v4.runtime.RuleContext`. ``` -------------------------------- ### getValuesListExpression Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/class-use/ExpressionsVisitor.html Gets the expression at the specified index from the context's ExprValuesContext, preserving null values or returning null if the index is invalid. ```APIDOC ## getValuesListExpression ### Description Gets the expression at the supplied index from the context's `MappingExpressionParser.ExprValuesContext` {@link ExprListContext}, preserving the null value (or returning null if the index is invalid). ### Method Signature `static com.fasterxml.jackson.databind.JsonNode getValuesListExpression(ExpressionsVisitor exprVisitor, MappingExpressionParser.Function_callContext ctx, int index)` ``` -------------------------------- ### accept Method Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.StringContext.html Accepts a ParseTreeVisitor to process the StringContext. ```APIDOC ## accept Method ### Signature public T accept(org.antlr.v4.runtime.tree.ParseTreeVisitor visitor) ### Description Accepts a visitor for the parse tree. This method allows for the implementation of the visitor pattern to perform operations on the parse tree nodes, including the StringContext. ``` -------------------------------- ### $pad(str, width [, char]) Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/package-summary.html Returns a copy of the string with padding to meet a minimum width. ```APIDOC ## $pad(str, width [, char]) ### Description Returns a copy of the string str with extra padding, if necessary, so that its total number of characters is at least the absolute value of the width parameter. ### Method Function ### Parameters - **str** (string) - The input string. - **width** (number) - The minimum desired width of the string. - **char** (string, optional) - The character to use for padding. Defaults to a space. ### Response Example { "example": " 123" } ``` -------------------------------- ### SubstringAfterFunction Usage Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/SubstringAfterFunction.html The SubstringAfterFunction is used to get the portion of a string that appears after a specified delimiter. It supports using the context value if the primary string is not provided. ```APIDOC ## $substringAfter(str, chars) ### Description Returns the substring after the first occurrence of the character sequence `chars` in `str`. If `str` is not specified (i.e., this function is invoked with only one argument), then the context value is used as the value of `str`. If `str` does not contain `chars`, then it returns `str`. An error is thrown if `str` and `chars` are not strings. ### Parameters * **str** (string) - The string to search within. * **chars** (string) - The character sequence to find. ### Examples ```jsonata $substringAfter("Hello World", " ") == "World" $substringAfter("Hello World", "o") == " World" $substringAfter("Hello World", "xyz") == "Hello World" ``` ### Error Handling * Throws an error if `str` or `chars` are not strings. ``` -------------------------------- ### Thread-Safe Evaluation with evaluateSynced Source: https://context7.com/ibm/jsonata4java/llms.txt Use `evaluateSynced` to safely share a single `Expressions` instance across multiple threads. Ensure proper setup of `ObjectMapper` and `ExecutorService`. ```java import com.api.jsonata4java.expressions.Expressions; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class ThreadSafeExample { public static void main(String[] args) throws Exception { Expressions sharedExpr = Expressions.parse("$uppercase(name)"); ObjectMapper mapper = new ObjectMapper(); ExecutorService pool = Executors.newFixedThreadPool(4); String[] inputs = { "{\"name\":\"alice\"}", "{\"name\":\"bob\"}", "{\"name\":\"carol\"}" }; for (String input : inputs) { JsonNode data = mapper.readTree(input); pool.submit(() -> { try { // evaluateSynced is safe for concurrent access JsonNode result = sharedExpr.evaluateSynced(data); System.out.println(result.asText()); // "ALICE", "BOB", "CAROL" } catch (Exception e) { e.printStackTrace(); } }); } pool.shutdown(); } } ``` -------------------------------- ### StringContext Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.StringContext.html Initializes a new instance of the StringContext class. ```APIDOC ## StringContext Constructor ### Signature public StringContext(MappingExpressionParser.ExprContext ctx) ### Description Initializes a new instance of the StringContext class, taking an ExprContext as an argument. ``` -------------------------------- ### VarListContext Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.VarListContext.html Initializes a new instance of the VarListContext class. ```APIDOC public VarListContext(org.antlr.v4.runtime.ParserRuleContext parent, int invokingState) ``` -------------------------------- ### $now() Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/package-summary.html Generates a UTC timestamp in ISO 8601 compatible format and returns it as a string. ```APIDOC ## $now() ### Description Generates a UTC timestamp in ISO 8601 compatible format and returns it as a string. ### Method Function ### Parameters None ### Response Example { "example": "2023-10-27T10:30:00Z" } ``` -------------------------------- ### Evaluate JSONata Expression in Java Source: https://github.com/ibm/jsonata4java/blob/master/.README.md.html Example code demonstrating how to parse a JSON string into a JsonNode object and evaluate a JSONata expression against it. Requires Jackson library for JSON processing. ```java package com.api.jsonata4java; import java.io.IOException; import com.api.jsonata4java.expressions.EvaluateException; import com.api.jsonata4java.expressions.EvaluateRuntimeException; import com.api.jsonata4java.expressions.Expressions; import com.api.jsonata4java.expressions.ParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; public class Test { public static void main(String[] args) { Expressions expr = null; ObjectMapper mapper = new ObjectMapper(); JsonNode jsonObj = null; String json = "{ \"a\":1, \"b\":2, \"c\":[1,2,3,4,5] }"; String expression = "$sum(c)"; try { jsonObj = mapper.readTree(json); } catch (IOException e1) { e1.printStackTrace(); } try { System.out.println("Using json:\n" + mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObj)); System.out.println("expression=" + expression); expr = Expressions.parse(expression); } catch (ParseException e) { System.err.println(e.getLocalizedMessage()); } catch (EvaluateRuntimeException ere) { System.out.println(ere.getLocalizedMessage()); } catch (JsonProcessingException e) { e.printStackTrace(); } try { System.out.println("evaluate returns:"); JsonNode result = expr.evaluate(jsonObj); if (result == null) { System.out.println("** no match **"); } else { System.out.println("" + mapper.writerWithDefaultPrettyPrinter().writeValueAsString(result)); } } catch (EvaluateException | JsonProcessingException e) { System.err.println(e.getLocalizedMessage()); } } } ``` -------------------------------- ### $now() Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/class-use/Function.html Generates a UTC timestamp in ISO 8601 compatible format and returns it as a string. ```APIDOC ## $now() ### Description Generates a UTC timestamp in ISO 8601 compatible format and returns it as a string. ``` -------------------------------- ### Create Bindings from JSON with Expression.createBindings Source: https://context7.com/ibm/jsonata4java/llms.txt Convert a JSON object into a list of Bindings. String values starting with 'function' become FUNCTION bindings; others become VARIABLE bindings. ```java import com.api.jsonata4java.Binding; import com.api.jsonata4java.Expression; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import java.util.List; public class CreateBindingsExample { public static void main(String[] args) throws Exception { ObjectMapper mapper = new ObjectMapper(); JsonNode bindingObj = mapper.readTree( "{\"threshold\": 100, \"label\": \"High\", \"tag\": \"function($v){ $v & \"-tag\" }\"}" ); List bindings = Expression.createBindings(bindingObj); // bindings[0]: VARIABLE $threshold = 100 // bindings[1]: VARIABLE $label = "High" // bindings[2]: FUNCTION $tag = function($v){ $v & "-tag" } Expression expr = Expression.jsonata("$tag(label) & \" \" & $string(threshold)"); JsonNode result = expr.evaluate(mapper.createObjectNode(), bindings); System.out.println(result.asText()); // "High-tag 100" } } ``` -------------------------------- ### Var_assignContext Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.Var_assignContext.html Initializes a new instance of the Var_assignContext class. ```APIDOC ## Var_assignContext Constructor ### Description Initializes a new instance of the Var_assignContext class. ### Parameters * **ctx** (MappingExpressionParser.ExprContext) - The context for the expression. ### Signature public Var_assignContext(MappingExpressionParser.ExprContext ctx) ``` -------------------------------- ### Expression.createBindings(JsonNode) Source: https://context7.com/ibm/jsonata4java/llms.txt A static helper method to convert a JSON object into a list of `Binding` objects. String values starting with 'function' are treated as function bindings, others as variable bindings. ```APIDOC ## `Expression.createBindings(JsonNode jsonNode)` ### Description This static helper method converts a JSON object into a `List`. String values within the JSON object that start with the prefix `"function"` are interpreted as function declarations and create FUNCTION type bindings. All other string values, and non-string values, are treated as VARIABLE type bindings. ### Method `Expression.createBindings` ### Parameters #### Path Parameters - **jsonNode** (JsonNode) - Required - The JSON object to convert into bindings. ### Request Example ```java JsonNode bindingObj = mapper.readTree( "{\"threshold\": 100, \"label\": \"High\", \"tag\": \"function($v){ $v & \"-tag\" }\"}" ); List bindings = Expression.createBindings(bindingObj); // bindings will contain: // - VARIABLE $threshold = 100 // - VARIABLE $label = "High" // - FUNCTION $tag = function($v){ $v & "-tag" } ``` ### Response Returns a `List` representing the variables and functions defined in the input `JsonNode`. ``` -------------------------------- ### Context_refContext Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.Context_refContext.html Initializes a new instance of the Context_refContext class. ```APIDOC ## Constructor: Context_refContext ### Description Initializes a new instance of the Context_refContext class. ### Parameters * **ctx** (MappingExpressionParser.ExprContext) - The parent expression context. ``` -------------------------------- ### Conditional Filtering with ContainsFunction Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/functions/ContainsFunction.html Uses the $contains function within a predicate to filter a list of phone numbers, selecting only those that start with '077'. The context value 'number' is used as the string to check. ```jsonata Phone[$contains(number, /^077/)]=={ "type": "mobile", "number": "077 7700 1234" } ``` -------------------------------- ### prompt Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/JSONataUtils.html Displays a prompt and returns the user's trimmed response. ```APIDOC ## prompt ### Description Prints the supplied prompt (if not null) and returns the trimmed response. ### Method Signature `public static String prompt(String strPrompt)` ### Parameters #### Path Parameters - **strPrompt** (java.lang.String) - The prompt to be displayed. ### Returns The trimmed response to the prompt (may be the empty String ("" ) if nothing entered). ``` -------------------------------- ### Execute JSONata Expression in Java Source: https://github.com/ibm/jsonata4java/blob/master/README.md This example demonstrates parsing a JSON string into a JsonNode, defining a JSONata expression, parsing the expression, and evaluating it against the JSON object. It includes error handling for parsing and evaluation exceptions. ```java package com.api.jsonata4java; import java.io.IOException; import com.api.jsonata4java.expressions.EvaluateException; import com.api.jsonata4java.expressions.EvaluateRuntimeException; import com.api.jsonata4java.expressions.Expressions; import com.api.jsonata4java.expressions.ParseException; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; public class Test { public static void main(String[\ ] args) { Expressions expr = null; ObjectMapper mapper = new ObjectMapper(); JsonNode jsonObj = null; String json = "{ \"a\":1, \"b\":2, \"c\":[1,2,3,4,5] }"; String expression = "$sum(c)"; try { jsonObj = mapper.readTree(json); } catch (IOException e1) { e1.printStackTrace(); } try { System.out.println("Using JSON:\n" + mapper.writerWithDefaultPrettyPrinter().writeValueAsString(jsonObj)); System.out.println("expression=" + expression); expr = Expressions.parse(expression); } catch (ParseException e) { System.err.println(e.getLocalizedMessage()); } catch (EvaluateRuntimeException ere) { System.out.println(ere.getLocalizedMessage()); } catch (JsonProcessingException e) { e.printStackTrace(); } try { System.out.println("evaluate returns:"); JsonNode result = expr.evaluate(jsonObj); if (result == null) { System.out.println("** no match **"); } else { System.out.println("" + mapper.writerWithDefaultPrettyPrinter().writeValueAsString(result)); } } catch (EvaluateException | JsonProcessingException e) { System.err.println(e.getLocalizedMessage()); } } } ``` -------------------------------- ### Var_recallContext Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.Var_recallContext.html Initializes a new instance of the Var_recallContext class. ```APIDOC ## Var_recallContext Constructor ### Description Initializes a new instance of the Var_recallContext class. ### Parameters * **ctx** (MappingExpressionParser.ExprContext) - The expression context to copy from. ``` -------------------------------- ### enterRule Method Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.NullContext.html Enters the rule for this context, notifying the listener. ```APIDOC ## enterRule Method ### Description Called when entering the rule associated with this context. It notifies the provided `ParseTreeListener`. ### Parameters * **listener** (`ParseTreeListener`) - The listener to notify. ``` -------------------------------- ### Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionLexer.html Initializes a new instance of the MappingExpressionLexer with the specified character stream. ```APIDOC ## MappingExpressionLexer(CharStream input) ### Description Constructs a new MappingExpressionLexer instance. ### Parameters * **input** (CharStream) - The character stream to be tokenized. ``` -------------------------------- ### Demonstrate JSONata4Java Array Functions in Java Source: https://context7.com/ibm/jsonata4java/llms.txt This Java example shows how to use various JSONata built-in array functions such as $count, $append, $distinct, $sort, $reverse, $map, $filter, $reduce, and $zip with Expressions.parse().evaluate(). ```java import com.api.jsonata4java.expressions.Expressions; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.node.JsonNodeFactory; public class ArrayFunctionsExample { public static void main(String[] args) throws Exception { JsonNode nil = JsonNodeFactory.instance.objectNode(); JsonNode data = new ObjectMapper().readTree( "{\"orders\": [{\"id\":1,\"val\":10},{\"id\":2,\"val\":30},{\"id\":1,\"val\":20}]}" ); // $count, $append, $distinct System.out.println(Expressions.parse("$count([1,2,3])").evaluate(nil)); // 3 System.out.println(Expressions.parse("$append([1,2],[3,4])").evaluate(nil)); // [1,2,3,4] System.out.println(Expressions.parse("$distinct([1,2,1,3,2])").evaluate(nil)); // [1,2,3] System.out.println(Expressions.parse("$sort([3,1,2])").evaluate(nil)); // [1,2,3] System.out.println(Expressions.parse("$reverse([1,2,3])").evaluate(nil)); // [3,2,1] // $map with lambda System.out.println(Expressions.parse("$map([1..5], $string)").evaluate(nil)); // ["1","2","3","4","5"] // $filter System.out.println(Expressions.parse( "$filter(orders, function($o){ $o.val > 15 })" ).evaluate(data)); // [{"id":2,"val":30},{"id":1,"val":20}] // $reduce System.out.println(Expressions.parse( "$reduce([1,2,3,4], function($prev,$curr){ $prev + $curr })" ).evaluate(nil)); // 10 // $zip System.out.println(Expressions.parse("$zip([1,2,3],[\"a\",\"b\",\"c\"])").evaluate(nil)); // [[1,"a"],[2,"b"],[3,"c"]] } } ``` -------------------------------- ### JSONata Legacy Regex Conversion Example Source: https://github.com/ibm/jsonata4java/blob/master/README.md Shows the conversion required for older JSONata4Java versions (<= 1.7.9) that used string literals for regex patterns. Convert string patterns to the '//' syntax for version 2.0.0 and later. ```jsonata $replace("foo bar", "fo.*ar", "Foo Bar") ``` -------------------------------- ### Comp_opContext Fields and Constructor Source: https://github.com/ibm/jsonata4java/blob/master/docs/com/api/jsonata4java/expressions/generated/MappingExpressionParser.Comp_opContext.html Details on the fields and constructor of the Comp_opContext class. ```APIDOC ## Comp_opContext Fields and Constructor ### Fields #### op ```java public org.antlr.v4.runtime.Token op ``` * **Description**: The token representing the comparison operator. ### Constructor #### Comp_opContext ```java public Comp_opContext(MappingExpressionParser.ExprContext ctx) ``` * **Description**: Constructs a `Comp_opContext` with the given expression context. ```