Assuming I have 2 arrays of JSON objects that look like this:
Resources
[{ "DefinitionId": 193041, "ResourceId": -2147290607, "AssetId": 193041 }, { "DefinitionId": 193042, "ResourceId": -2147290603, "AssetId": 193042 }]
Resourceource
[193041, 193041, 193041, 193042]
Usage example:
I need to list the details from my JSONObject resource for each ResourceId. For example, I want to output an AssetId for each ResourceId in ResourceIds .
My plan:
I thought it would be an elegant solution to convert my Resources JSON into an associative array so that I could access the AssetId for my ResourceId '193041' as follows: Resources[193041].AssetId . Problem: I could only think of long code to convert my above Resources JSON into an associative JSON object.
Question:
How can I convert the above array of JSON Resources objects to an array of associative objects with ResourceId key?
Desired .json resources:
{ "-2147290607": { "DefinitionId": 193041, "ResourceId": -2147290607, "AssetId": 193041 }, "-2147290603": { "DefinitionId": 193042, "ResourceId": -2147290603, "AssetId": 193042 } }
kentor
source share