Research is not getting me there.
Description:
I'm storing an hasmap into a json formated file (kind of associative array). I'm making my own parsing functions, since i never found how to convert an array into a json string. I found lot's of code samples converting a json string into an array, but not the oposite. If someone point me into some sample code , i'd be apreciated.
But for the moment the real issue is: i have my json string (2D associative array) to convert back to an hasmap and i want to fetch values without knowing the key names.
Pseudo sample data:
"parent_01" = ("child_01","child_02","child_03")
"parent_02" = ("child_01","child_02","child_03")
"parent_03" = ("child_01","child_02","child_03")
Code:
i can fetch data like this
but what i really need is this
maxtrix.net
Description:
I'm storing an hasmap into a json formated file (kind of associative array). I'm making my own parsing functions, since i never found how to convert an array into a json string. I found lot's of code samples converting a json string into an array, but not the oposite. If someone point me into some sample code , i'd be apreciated.
But for the moment the real issue is: i have my json string (2D associative array) to convert back to an hasmap and i want to fetch values without knowing the key names.
Pseudo sample data:
"parent_01" = ("child_01","child_02","child_03")
"parent_02" = ("child_01","child_02","child_03")
"parent_03" = ("child_01","child_02","child_03")
Code:
i can fetch data like this
- JSONArray entries = someData.getJSONArray("parent_01");
but what i really need is this
- JSONArray level_01 = someData.getJSONArray();
- for(int i = 0; i<level_01.size, i++)
- {
- String parentkey = level_01[i].getkey; // storing "parent_01" into parentkey ... and so on
- String parentvalue = level_01[i].getvalue; // storing "child_01","child_02","child_03" into parentvalue ... and so on
- JSONArray level_02 = someData.getJSONArray(level_01[i].getkey);
- for(int j = 0; j<level_02.size, j++)
- {
- String childkey = level_02[i].getkey; // storing "0" into parentkey
- String childvalue = level_02[i].getvalue; // storing "child_01" into parentvalue ...and so on
- }
- }
maxtrix.net
1