cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Don’t miss your chance to experience Discovery Summit Europe at our best available rate! Early bird registration through 31 Oct.
  • Image to Table JMP extension imports single or batch images as data tables. Useful to extract curves from pictures or convert image data to curve data to use in analyses like Functional Data Explorer. Download and install the extension.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
Mick1
Level I

JSON code returning unwanted curly braces

Hi, 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

4 REPLIES 4
jthi
Super User

Re: JSON code returning unwanted curly braces

You 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

-Jarmo
Mick1
Level I

Re: JSON code returning unwanted curly braces

Thank 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?

jthi
Super User

Re: JSON code returning unwanted curly braces

This 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);
-Jarmo
ih
Super User (Alumni) ih
Super User (Alumni)

Re: JSON code returning unwanted curly braces

Just 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];

Recommended Articles