Quote from tilesoft on July 19, 2024, 4:43 amHi again, I know that is my script is so stupid but how can I resolve the problem?
LoadJSON "https://jaaak.ir/category/jdhhXhZx3G33XWYzj05DN.json" [ns_category_db] SetVar [ns_category_counter] 0 .========================================= While 0 <= 2 SetVar [ns_category[ns_category_counter]_name] [ns_category_db([ns_category_counter]).name] SetVar [ns_category[ns_category_counter]_id] [ns_category_db([ns_category_counter]).id] SetVar [ns_category[ns_category_counter]_slug] [ns_category_db([ns_category_counter]).slug] SetVar [ns_category[ns_category_counter]_statue] [ns_category_db([ns_category_counter]).statue] Math "[ns_category_counter]+1" -1 [ns_category_counter] EndWhileI want get and read json file like this:
[ { "name": "null", "id": "null", "slug": "null", "statue": "Disable" }, { "name": "null", "id": "null", "slug": "null", "statue": "Disable" }, { "name": "null", "id": "null", "slug": "null", "statue": "Disable" } ]And then list all "name" into a comobox
Hi again, I know that is my script is so stupid but how can I resolve the problem?
LoadJSON "https://jaaak.ir/category/jdhhXhZx3G33XWYzj05DN.json" [ns_category_db]
SetVar [ns_category_counter] 0
.=========================================
While 0 <= 2
SetVar [ns_category[ns_category_counter]_name] [ns_category_db([ns_category_counter]).name]
SetVar [ns_category[ns_category_counter]_id] [ns_category_db([ns_category_counter]).id]
SetVar [ns_category[ns_category_counter]_slug] [ns_category_db([ns_category_counter]).slug]
SetVar [ns_category[ns_category_counter]_statue] [ns_category_db([ns_category_counter]).statue]
Math "[ns_category_counter]+1" -1 [ns_category_counter]
EndWhile
I want get and read json file like this:
[
{
"name": "null",
"id": "null",
"slug": "null",
"statue": "Disable"
},
{
"name": "null",
"id": "null",
"slug": "null",
"statue": "Disable"
},
{
"name": "null",
"id": "null",
"slug": "null",
"statue": "Disable"
}
]
And then list all "name" into a comobox

Quote from roccocogliano on July 19, 2024, 10:03 amHi @tilesoft,
I don't know what you want to do but surely the condition of the while loop (While 0 <= 2) is wrong. It's an infinite cycle that will never end. Then to loop through a json object use LoopObject (https://webhelp.visualneo.com/Conditional.html) and not the normal while loop.
Hi @tilesoft,
I don't know what you want to do but surely the condition of the while loop (While 0 <= 2) is wrong. It's an infinite cycle that will never end. Then to loop through a json object use LoopObject (https://webhelp.visualneo.com/Conditional.html) and not the normal while loop.
Quote from tilesoft on July 21, 2024, 1:12 amThanks, You are right! @roccocogliano
In other words, I want list "name" of this json file to combo box:
[ { "name": "null", "id": "null", "slug": "null", "statue": "Disable" }, { "name": "null", "id": "null", "slug": "null", "statue": "Disable" }, { "name": "null", "id": "null", "slug": "null", "statue": "Disable" } ]And the number of json items is not clear and any number of items that are available should be listed in the combo box
Thanks, You are right! @roccocogliano
In other words, I want list "name" of this json file to combo box:
[
{
"name": "null",
"id": "null",
"slug": "null",
"statue": "Disable"
},
{
"name": "null",
"id": "null",
"slug": "null",
"statue": "Disable"
},
{
"name": "null",
"id": "null",
"slug": "null",
"statue": "Disable"
}
]
And the number of json items is not clear and any number of items that are available should be listed in the combo box

Quote from luishp on July 21, 2024, 7:58 pm@tilesoft please check the attached app.
BeginJS $App.data=[ { "name": "One", "id": "null", "slug": "null", "statue": "Disable" }, { "name": "Two", "id": "null", "slug": "null", "statue": "Disable" }, { "name": "Three", "id": "null", "slug": "null", "statue": "Disable" } ] EndJS .Create the array we have assigned to the combobox CreateEmptyArray [myarray] .Loop through the JSON data Loop 0 [data.length-1] [n] .Add item to the array ArrayAddItem [myarray] [data([n]).name] EndLoopRegards.
@tilesoft please check the attached app.
BeginJS
$App.data=[
{
"name": "One",
"id": "null",
"slug": "null",
"statue": "Disable"
},
{
"name": "Two",
"id": "null",
"slug": "null",
"statue": "Disable"
},
{
"name": "Three",
"id": "null",
"slug": "null",
"statue": "Disable"
}
]
EndJS
.Create the array we have assigned to the combobox
CreateEmptyArray [myarray]
.Loop through the JSON data
Loop 0 [data.length-1] [n]
.Add item to the array
ArrayAddItem [myarray] [data([n]).name]
EndLoop
Regards.
Uploaded files:Quote from tilesoft on July 22, 2024, 4:41 amThanks, This worked.
If user selected "name" from item 2 of json, Now how can I read item 2 "id"?
I do this:
ListBoxGetSelectedIndex "Combobox" [selected_index] SetVar [selected_id] [data([selected_index]).id]Is it true?
Thanks, This worked.
If user selected "name" from item 2 of json, Now how can I read item 2 "id"?
I do this:
ListBoxGetSelectedIndex "Combobox" [selected_index] SetVar [selected_id] [data([selected_index]).id]
Is it true?

Quote from luishp on July 22, 2024, 7:51 am@tilesoft no, it's quite easier. Please check the attached app.
The key point is this:.Loop through the JSON data Loop 0 [data.length-1] [n] .Add item to the array and the associated value separated by | ArrayAddItem [myarray] "[data([n]).name]|[data([n]).id]" EndLoopRegards.
@tilesoft no, it's quite easier. Please check the attached app.
The key point is this:
.Loop through the JSON data Loop 0 [data.length-1] [n] .Add item to the array and the associated value separated by | ArrayAddItem [myarray] "[data([n]).name]|[data([n]).id]" EndLoop
Regards.
Uploaded files:
Quote from tilesoft on July 24, 2024, 1:52 amThanks Luis,
And my last question is if user select the name of second item of this json, And we want select all sub-items of user selected such as name, id, slug, statue from json, How can it happen?
Thanks Luis,
And my last question is if user select the name of second item of this json, And we want select all sub-items of user selected such as name, id, slug, statue from json, How can it happen?

Quote from luishp on July 24, 2024, 7:38 am.Loop through the JSON data to get all the information from the selected id. Loop 0 [data.length-1] [n] If [data([n]).id] == [selectedId] SetVar [name] [data([n]).name] SetVar [slug] [data([n]).slug] SetVar [statue] [data([n]).statue] SetVar [id] [data([n]).id] ExitLoop EndIf EndLoop@tilesoft
Now you have all the information stored in [name], [slug], [statue] and [id]
.Loop through the JSON data to get all the information from the selected id.
Loop 0 [data.length-1] [n]
If [data([n]).id] == [selectedId]
SetVar [name] [data([n]).name]
SetVar [slug] [data([n]).slug]
SetVar [statue] [data([n]).statue]
SetVar [id] [data([n]).id]
ExitLoop
EndIf
EndLoop
@tilesoft
Now you have all the information stored in [name], [slug], [statue] and [id]
Quote from tilesoft on July 25, 2024, 12:26 amThanks alot.
I know it's annoying, but please answer this question as well. Now that the user has selected the desired item in the combo box, how can the program delete all information and other items related to that item from the json file?
Thanks alot.
I know it's annoying, but please answer this question as well. Now that the user has selected the desired item in the combo box, how can the program delete all information and other items related to that item from the json file?

Quote from luishp on July 25, 2024, 12:05 pmNow that the user has selected the desired item in the combo box, how can the program delete all information and other items related to that item from the json file?
@tilesoft sorry I don't understand your question
Now that the user has selected the desired item in the combo box, how can the program delete all information and other items related to that item from the json file?
@tilesoft sorry I don't understand your question
Quote from tilesoft on July 26, 2024, 12:18 amLet me explain another way. Suppose, based on this example,
[ { "name": "null", "id": "null", "slug": "null", "statue": "Disable" }, { "name": "null", "id": "null", "slug": "null", "statue": "Disable" }, { "name": "null", "id": "null", "slug": "null", "statue": "Disable" } ]the user chooses the second item. Now, how can the program delete all the elements in the second item such as name, id, slug, statue from the json file?
Actually, my question has two parts.
The first part is, how can the program determine which item the user has chosen?
And the second part is how the program can delete all the elements related to the item selected by the user?
Let me explain another way. Suppose, based on this example,
[
{
"name": "null",
"id": "null",
"slug": "null",
"statue": "Disable"
},
{
"name": "null",
"id": "null",
"slug": "null",
"statue": "Disable"
},
{
"name": "null",
"id": "null",
"slug": "null",
"statue": "Disable"
}
]
the user chooses the second item. Now, how can the program delete all the elements in the second item such as name, id, slug, statue from the json file?
Actually, my question has two parts.
The first part is, how can the program determine which item the user has chosen?
And the second part is how the program can delete all the elements related to the item selected by the user?

Quote from luishp on July 26, 2024, 9:10 am@tilesoft please, note that your sample JSON data has not real data and will not work in a "real" app. The "id" should be "unique" and two diferent items should not share the same id value. That's a key point for working with data and databases. You need a "key" field.
Once you understand this, you can loop through the JSON data and find the record with the "id" you are looking for.
Then you can retrieve any data from that record or modify it.
To better manage data stored in a JSON file you can use neoSQL plugin. It allows to perform any SQL query over JSON data as if it was a real database.Regards.
@tilesoft please, note that your sample JSON data has not real data and will not work in a "real" app. The "id" should be "unique" and two diferent items should not share the same id value. That's a key point for working with data and databases. You need a "key" field.
Once you understand this, you can loop through the JSON data and find the record with the "id" you are looking for.
Then you can retrieve any data from that record or modify it.
To better manage data stored in a JSON file you can use neoSQL plugin. It allows to perform any SQL query over JSON data as if it was a real database.
Regards.