Page MenuHomeFeedback Tracker

Hashmap Serialization from Json data
New, NormalPublic

Description

Hashmap are great in Arma 3 but they could be better. This Feature Proposes that Hashmap be serialized from json data, and json files. This allows for more customization in Arma if we can create hashmaps from json. An example of this would be static loot list in Antistasi. Currently Antistasi doesn't not have a loot list because of the amount of work required to build such a list per faction we support. Json would reduce that complexity as we can build tools to help us create said list in a json form. However there is no engine command that can load or process a json like structure with easy. This is were the propose comes in. Below are a few proposed engine commands that would help with hashmap serialization from json.

private _jsonHashmap = createJsonHashMap;											// create the JsonHashMap data type in the engine
_jsonHashmap set '{
  "A3A": {
	"Faction": "AFRF",
	"StaticList": {
	  "rifle": [
		"Cup_rifle_ak19",
		"Cup_rifle_ak_18",
		"Cup_rifle_ak17"
	  ]
	}
  }
}';				  // set the serialize the hashmap from a string in the form of json.

private _jsonHashmap2 = createJsonHashMap;
_jsonHashmap2 setFromFile "@A3A-intercept-plugin/json/web_colors.json";			  // serialization of hashmap from a jsonFile;

_jsonHashmap merge _jsonHashmap2;													// merges in _jsonHashmap2 into _jsonHashmap 
_jsonHashmap deleteAt "colors";

private _isColorInMap = "colors" in _jsonHashmap;									// returns false as deleteAt removed colors

private _isColorInMap = "colors" inNested _jsonHashmap;							  // returns true as rifle is in the map but behind other objects

private _rifles = _jsonHashmap getNested ["A3A", "StaticList", "rifle"];			 // returns an array of rifles ["Cup_rifle_ak19","Cup_rifle_ak_18","Cup_rifle_ak17"]

private _faction = _jsonHashmap get "Faction";									   // return the value from key, returns [] because you need nested access 

_faction = _jsonHashmap getOrDefault ["Faction", "USMC"];							// returns the value from key or the default value if not found

_faction = _jsonHashmap getOrDefaultNested [["A3A", "Faction"],"USMC"];			  // returns the value from nested key or the default value if not found

private _keys = keys _jsonHashmap;												   // returns a list of keys in the jsonmap

private _count = count _jsonHashmap;												 // returns the count for keys

I have built a very naive attempt are creating all these commands as an reference example of implementation. That code is probably not the greatest but it does should that with the use of intercept you can create all the function necessary and have it work all the time.
https://github.com/killerswin2/A3A_intercept/blob/master/src/hashing/jsonHashMap.cpp

Given that this was intercept example Dedmen Should have a understand of what I am doing in the code.

Details

Severity
Feature
Resolution
Open
Reproducibility
N/A
Operating System
Windows 10 x64
Category
General

Event Timeline

Added image to show use cases.

This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
This comment was removed by Tenshi.
Tenshi added a subscriber: Tenshi.Oct 21 2022, 1:40 PM