JSON code returning unwanted curly bracesHi, I am hoping to get returned numbers only, though am getting results like: -
{1.6853394618}
Can anyone help re-write this: -
{1.6853394618, 1.1953542099, 0.5582366613, 0.4790270411, 0.4159308661, 0.4145532579, 0.3847474328, 0.1964273334, 0.1680691329, 0.1715601671,
0.2542918024, 0.1972811076, 0.2371273713}[Loc Sorted( [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], :Age )]
JMP 17.2.0
Automation and ScriptingRe: JSON code returning unwanted curly bracesYou will have to add additional index at the end of your return value [1] (or use other method of getting the value from the list which is returned). This is because you are using matrix as the index -> return value will also be matrix (or in this case a list)
Loc Sorted( [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], :Age )
You could also make the above part of your script to return only single value instead of matrix
Re: JSON code returning unwanted curly bracesThank you Jarmo. I have tried your suggestions, though no success as I am likely mis-interpretating them (I am a beginner at this). Could you give the entire code?
Re: JSON code returning unwanted curly bracesThis hopefully gives the idea what I mean
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
Row() = 1;
my_list = {1.6853394618, 1.1953542099, 0.5582366613, 0.4790270411, 0.4159308661, 0.4145532579,
0.3847474328, 0.1964273334, 0.1680691329, 0.1715601671, 0.2542918024, 0.1972811076, 0.2371273713
};
m = my_list[Loc Sorted([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], :Age)];
val = my_list[Loc Sorted([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], :Age)][1];
val2 = my_list[Loc Sorted([3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], :Age)[1]];
Show(m, val, val2);Re: JSON code returning unwanted curly bracesJust re-starting @jthi 's suggestion in a single line, if you know you are are only going to ask for a single value, you can just add [1] to the end of your line, like this:
{1.6853394618, 1.1953542099, 0.5582366613, 0.4790270411, 0.4159308661, 0.4145532579, 0.3847474328, 0.1964273334, 0.1680691329, 0.1715601671,
0.2542918024, 0.1972811076, 0.2371273713}[Loc Sorted( [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15], :Age )][1];