Page MenuHomeFeedback Tracker

JsonApiStruct unable to deserialise arrays
Assigned, NormalPublic

Description

I am using a JsonApiStruct to deserialise data returned via a REST client. The JsonApiStruct documentation page says that arrays are supported (although no examples are given): https://community.bistudio.com/wiki/Arma_Reforger:JsonApiStruct_Usage.

When attempting to deserialise a static float array using ExpandFromRAW() or LoadFromFile(), EJsonApiError.ETJSON_NOTARRAY is raised and the array retains its default value (all zeroes). Deserialising other simple types in the JsonApiStruct (strings, ints, etc) works as expected.

I have also been unable to deserialise as dynamic arrays either.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 11 x64
Operating System Version
23H2
Category
General
Steps To Reproduce

Simple test struct:

class TAG_TestStruct : JsonApiStruct
{
	float myArray[3];
	
	void TAG_TestStruct()
	{	
		RegV("myArray");
	}
	
	override void OnSuccess(int errorCode)
	{
		Print("Successfully expanded JSON");
	}
	
	override void OnError(int errorCode)
	{
		Print("Error expanding JSON: " + errorCode);
	}
}

Code to deserialise using struct:

class TAG_RestCallback : RestCallback
{
	ref TAG_TestStruct m_testStruct;
	
	override void OnError(int errorCode)
	{
		Print("OnError()");
	}
	
	override void OnTimeout()
	{
		Print("OnTimeout()");
	}

	override void OnSuccess(string data, int dataSize)
	{
		m_testStruct = new TAG_TestStruct();
		m_testStruct.ExpandFromRAW(data);
	}
}

Data sent: {"myArray": [1, 2, 3]}

Error EJsonApiError.ETJSON_NOTARRAY event is raised, and the m_testStruct.myArray has default value {0,0,0} instead of {1,2,3}

Additional Information

Reforger 1.2.0.102

Event Timeline

sjpritchard updated the task description. (Show Details)Jul 30 2024, 12:03 AM
sjpritchard updated the task description. (Show Details)
sjpritchard updated the task description. (Show Details)
sjpritchard updated the task description. (Show Details)
sjpritchard edited Steps To Reproduce. (Show Details)
Geez changed the task status from New to Assigned.Jul 30 2024, 10:47 AM
sjpritchard updated the task description. (Show Details)Jul 30 2024, 1:46 PM
sjpritchard edited Additional Information. (Show Details)Aug 1 2024, 1:48 PM