Can we assign a path to a variable in jsonata - jsonata

I am in a specific path in json and from this path I want to get the value of a parent key and the problem is I that the key I needed might be parent or grandparent or ancestor to that.
I am not sure to use %. or %.%. or %.%.%. or... So I want to write a function which checks weather %.variable exists or else it calls itself and checks for %.%. and so on till it find but I am not getting how to write this function like how can we assign the path to a variable and send as an argument to a function. Can anyone help me to write this function?

Related

How to get the matched key from ngx translate?

I have a directive that is sending a whole array of possible "fallback" keys to the Translate pipe's transform method (as the second param, "args"), and ngx somehow settles on the one that actually exists. I know the Translate pipe has a 'lastKey' property, but that turns out to not have the right value if a fallback is chosen.
Is there a way to get what path it actually translated?

JMeter retrieve value of value

I am using jmeter to test ldap.
As part of my test, I want to search for a random uid on each iteration. I did not find a straight forward answer to this. So my idea was to first select a random number 1-200 and saving that number as a variable named uid, that number would correspond to a UDV name.
For example
uid = 2 and 2 = A123456
in my udv list. However when trying to reference this variable in my ldap search filter.I am trying to use
(uid=${${uid}})
in hopes to get the value of the value of uid. However the search results just show this as a string.
<searchfilter>(uid=${${uid}})</searchfilter>
Is there another way to achieve what I am looking for?
Use __V function
${__V(${uid})}
The V (variable) function returns the result of evaluating a variable name expression. This can be used to evaluate nested variable references
${__V(A${N})} - works OK. A${N} becomes A1, and the __V function returns the value of A1
Perhaps the easiest would be going for __RandomFromMultipleVars() function?
Another option is using __V() function, it can combine and evaluate JMeter Variables

How to declare a set of parameters in omnetpp.ini

I have hosts of two types: wirelessHostA[0..N], wirelessHostB[0..N]. I want to declare each of hosts wirelessHostA[0..N] to send messages to respective wirelessHostB[0..N]. Example: A[0] sends to B[0], A[10] sends to B[10]. Expression-wise I have got something like this:
*.wirelessHostA[0..${N}].app[ * ].destAddresses = "wirelessHostB[0..${N}]"
although this one is not correct. I am a bit unsure about how to declare a variable that can be iterated during a run and not a value per run.
You should not see the lines in the INI file as assignments where you can create procedural constructs like loops etc. Instead think about them as pattern matching rules. When a module needs a parameter, it scans the INI file from start, line by line and tries to match the first part (i.e. the part before =) to the current module path. If it matches, it assigns the second part to the parameter. If not, in continues with the next line in the INI file.
So first, write a pattern rule, then a value that can be evaluated in that context. When you specify the value, you may refer to other parameters (that are available in the module's context) or you may refer to other extra contextual information, such as the matching submodule's index (if it is part of a vector). There are other functions to access the index of parent of etc.
In this case, we have a submodule vector of hosts where each one contains a submodule vector of apps. The index operator would return the index of the current context module (which is the position in the app vector), but we need actually the index of the parent of the app vector (which is the host vector). There is a NED function for this too, called parentIndex(). So the solution would look like this:
*.wirelessHostA[*].app[*].destAddresses = "wirelessHostB[" + string(parentIndex()) + "]"
See https://doc.omnetpp.org/omnetpp/manual/#sec:ned-functions:category-ned for more info.

UiPath: Collection.contains("string") doesn't appear to be returning Boolean as expected

First I use a "Get processes" activity which assigns its result to a variable called currentProcessesCollection which is of type Collection
Next I want to check this condition in and If activity currentProcessesCollection.Contains("OUTLOOK")
I'm getting 'string' cannot be converted to type System.Diagnostics.Process'
I'm kind of flummoxed by this and wondering if anyone knows some other way to do this. I was kind of hoping that writing out the problem would help, it didn't. Thanks for any help in advance. I need to find out if outlook is running.
As you correctly said, currentProcessCollection contains a collection of Process objects. As such, Contains requires another Process object in order to compare them, when you provided the string object "OUTLOOK.EXE".
If you want to search whether at least one process by name exists, just assign the following to a boolean variable (just replace Scan with any process name):
processCollection.Where(Function(x) x.ProcessName = "Scan").Count > 0

Uiimport does not save variable to base workspace

I tried using uiimport to load a file to the base workspace.....It worked first time....but after trying again after a while...I wasnt seeing the variable in the base work space.
I used the default variable name which is given by 'uiimport".
This was the command I used:
uiimport(filename)
And two variables where created by default..."data" and "textdata"(which is the header)....but now when i run it is no longer saved in the base workspace
I do not want to assign a variable to the uiimport like so...
K = uiimport(filename)
assignin(base,'green',K)
I do not want to do that because
My dataset has a text header and the data itself, and doing this would assign both "textdata" and "data" to "green" variable
How would I be able to get the dimensions of ONLY the "data" in green and how would I pass only "data"(which is in the green variable in the workspace.."rmbr"...the green variable holds both "data" and "textdata") to another function.
I was able to do all this when the uiimport automatically saved the variables in the base workspace....but somehow now it doesn't.
I would appreciate any help or tips on this matter
One thing to note about UIIMPORT is that it will save variables to the workspace from which it is called. If you call it from the command window, the variables will be saved to the base workspace. However, if you call it from within a function, the variables will be saved in the workspace of the function. This may explain why you are not seeing the variables appear in the base workspace.
One solution would be to do the following, using the function ASSIGNIN:
K = uiimport(filename); %# Load your data into a structure K
assignin('base','green',K.data); %# Get the "data" field from K and assign
%# it to variable "green" in the base
%# workspace
Use
K = uiimport(filename);
green=[K.data];
to get only numerical data in your green variable.
uiimport returns file data as a structure containing the fields data, textdata, and colheaders. To return only the data field, assign another variable as K.data, or simply reassign K=K.data if you don't want the rest of the information contained by the file.

Resources