12-26-2020 12:00 PM
Dear all,
can anybody with the following JSON string I want to unflatten to LabVIEW cluster/array? An online JSON validator told me the JSON string is valid, but I'm not able to unflatten. I guess the biggest problem are the different cluster names 1st_Cluster to 3rd_Cluster.
Any help is much appreciated.
{
"1st_Cluster":{"pair_id":1039,"price_precision":4,"amount_precision":2,"min_amount":"0.01","max_amount":"-1","min_total":"10","max_total":"-1"},
"2nd_Cluster":{"pair_id":407,"price_precision":7,"amount_precision":2,"min_amount":"35.42","max_amount":"-1","min_total":"0.005","max_total":"-1"},
"3rd_Cluster":{"pair_id":937,"price_precision":6,"amount_precision":2,"min_amount":"0.01","max_amount":"-1","min_total":"0.005","max_total":"-1"}
}
Solved! Go to Solution.
12-26-2020 03:07 PM
Seemed easy enough to me. You just need to name those 3 clusters in your master cluster.
My guess is that some of your inner elements are numbers, and others are strings. So you need to set those types correctly.
12-26-2020 04:08 PM
Thanks a lot for your fast help, RavensFan.
I was able to parse all inner elements without any problem.
The naming of the 3 clusters is another story. The naming and count of clusters in my posted question is just an example. The real data contains hundreds of clusters, all titled differently. The cluster count is changing frequently.
So, a generic solution is crucial. Can't create controls with hundreds of clusters.
12-26-2020 04:12 PM
Sorry, I didn't write that the real data contains a variable count of clusters with variable labels.
12-26-2020 05:43 PM
If you install the JSONtext library using VI Package Manager, you'll find a function that can convert your JSON into an array of item names and subclusters. The standard JSON functions in LabVIEW are not that flexible.
12-26-2020 10:44 PM
@Xenia1986 wrote:
Thanks a lot for your fast help, RavensFan.
I was able to parse all inner elements without any problem.
The naming of the 3 clusters is another story. The naming and count of clusters in my posted question is just an example. The real data contains hundreds of clusters, all titled differently. The cluster count is changing frequently.
So, a generic solution is crucial. Can't create controls with hundreds of clusters.
Well that is a completely different problem and more complicated situation than what you asked.
12-27-2020 12:44 AM
@drjdpowell wrote:
If you install the JSONtext library using VI Package Manager, you'll find a function that can convert your JSON into an array of item names and subclusters. The standard JSON functions in LabVIEW are not that flexible.
Thanks a lot. This plugin made the job. I used the function JSONtext:Get All Object Items.vi to retrieve all the different cluster names into 1 array and their content into another array. Now it's pretty comfortable to build the LV cluster array I need. This library saved my day....thanks again.