Offnix
Offnix

Reputation: 27

Dynamic Object Deserialization to class

So this has been bugging me for the last day or two and I just can't figure out why its happening.

Currently, I am trying to Deserialize a dynamic object into a class for use. But for some reason, I receive this error: (My Class) has some invalid arguments. The code I'm using to deserialize:

dynamic BaseOffsets = JsonConvert.DeserializeObject(File.ReadAllText(Environment.CurrentDirectory + @"\Offsets.json"));
            Netvars = JsonConvert.DeserializeObject<netvars>(BaseOffsets.netvars);
            Signatures = JsonConvert.DeserializeObject<signatures>(BaseOffsets.signatures);

So, first of all, I checked the values against the class. They all match up. But still, the debugger tells me there is a magic extra variable inside the class. Even after direct comparison, I could not find the variable in either class that it is causing it in.

So then I broke down the JSON structure to see if there was something I had missed. But no the variables are still the same. My class code:

public class netvars
{
    public Int32 m_ArmorValue { get; set; }
    public Int32 m_Collision { get; set; }
    public Int32 m_CollisionGroup { get; set; }
    public Int32 m_Local { get; set; }
    public Int32 m_MoveType { get; set; }
    public Int32 m_OriginalOwnerXuidHigh { get; set; }
    public Int32 m_OriginalOwnerXuidLow { get; set; }
    public Int32 m_aimPunchAngle { get; set; }
    public Int32 m_aimPunchAngleVel { get; set; }
    public Int32 m_bGunGameImmunity { get; set; }
    public Int32 m_bHasDefuser { get; set; }
    public Int32 m_bHasHelmet { get; set; }
    public Int32 m_bInReload { get; set; }
    public Int32 m_bIsDefusing { get; set; }
    public Int32 m_bIsScoped { get; set; }
    public Int32 m_bSpotted { get; set; }
    public Int32 m_bSpottedByMask { get; set; }
    public Int32 m_clrRender { get; set; }
    public Int32 m_dwBoneMatrix { get; set; }
    public Int32 m_fAccuracyPenalty { get; set; }
    public Int32 m_fFlags { get; set; }
    public Int32 m_flFallbackWear { get; set; }
    public Int32 m_flFlashDuration { get; set; }
    public Int32 m_flFlashMaxAlpha { get; set; }
    public Int32 m_flNextPrimaryAttack { get; set; }
    public Int32 m_hActiveWeapon { get; set; }
    public Int32 m_hMyWeapons { get; set; }
    public Int32 m_hObserverTarget { get; set; }
    public Int32 m_hOwner { get; set; }
    public Int32 m_hOwnerEntity { get; set; }
    public Int32 m_iAccountID { get; set; }
    public Int32 m_iClip1 { get; set; }
    public Int32 m_iCompetitiveRanking { get; set; }
    public Int32 m_iCompetitiveWins { get; set; }
    public Int32 m_iCrosshairId { get; set; }
    public Int32 m_iEntityQuality { get; set; }
    public Int32 m_iFOVStart { get; set; }
    public Int32 m_iGlowIndex { get; set; }
    public Int32 m_iHealth { get; set; }
    public Int32 m_iItemDefinitionIndex { get; set; }
    public Int32 m_iItemIDHigh { get; set; }
    public Int32 m_iObserverMode { get; set; }
    public Int32 m_iShotsFired { get; set; }
    public Int32 m_iState { get; set; }
    public Int32 m_iTeamNum { get; set; }
    public Int32 m_lifeState { get; set; }
    public Int32 m_nFallbackPaintKit { get; set; }
    public Int32 m_nFallbackSeed { get; set; }
    public Int32 m_nFallbackStatTrak { get; set; }
    public Int32 m_nForceBone { get; set; }
    public Int32 m_nTickBase { get; set; }
    public Int32 m_rgflCoordinateFrame { get; set; }
    public Int32 m_szCustomName { get; set; }
    public Int32 m_szLastPlaceName { get; set; }
    public Int32 m_thirdPersonViewAngles { get; set; }
    public Int32 m_vecOrigin { get; set; }
    public Int32 m_vecVelocity { get; set; }
    public Int32 m_vecViewOffset { get; set; }
    public Int32 m_viewPunchAngle { get; set; }
}

public class signatures
{
    public Int32 dwClientState { get; set; }
    public Int32 dwClientState_GetLocalPlayer { get; set; }
    public Int32 dwClientState_IsHLTV { get; set; }
    public Int32 dwClientState_Map { get; set; }
    public Int32 dwClientState_MapDirectory { get; set; }
    public Int32 dwClientState_MaxPlayer { get; set; }
    public Int32 dwClientState_PlayerInfo { get; set; }
    public Int32 dwClientState_State { get; set; }
    public Int32 dwClientState_ViewAngles { get; set; }
    public Int32 dwEntityList { get; set; }
    public Int32 dwForceAttack { get; set; }
    public Int32 dwForceAttack2 { get; set; }
    public Int32 dwForceBackward { get; set; }
    public Int32 dwForceForward { get; set; }
    public Int32 dwForceJump { get; set; }
    public Int32 dwForceLeft { get; set; }
    public Int32 dwForceRight { get; set; }
    public Int32 dwGameDir { get; set; }
    public Int32 dwGameRulesProxy { get; set; }
    public Int32 dwGetAllClasses { get; set; }
    public Int32 dwGlobalVars { get; set; }
    public Int32 dwGlowObjectManager { get; set; }
    public Int32 dwInput { get; set; }
    public Int32 dwInterfaceLinkList { get; set; }
    public Int32 dwLocalPlayer { get; set; }
    public Int32 dwMouseEnable { get; set; }
    public Int32 dwMouseEnablePtr { get; set; }
    public Int32 dwPlayerResource { get; set; }
    public Int32 dwRadarBase { get; set; }
    public Int32 dwSensitivity { get; set; }
    public Int32 dwSensitivityPtr { get; set; }
    public Int32 dwSetClanTag { get; set; }
    public Int32 dwViewMatrix { get; set; }
    public Int32 dwWeaponTable { get; set; }
    public Int32 dwWeaponTableIndex { get; set; }
    public Int32 dwYawPtr { get; set; }
    public Int32 dwZoomSensitivityRatioPtr { get; set; }
    public Int32 dwbSendPackets { get; set; }
    public Int32 dwppDirect3DDevice9 { get; set; }
    public Int32 m_pStudioHdr { get; set; }
    public Int32 m_pitchClassPtr { get; set; }
    public Int32 m_yawClassPtr { get; set; }
}

If anyone can help me i would be so grateful, i've been searching for several hours and i'm still just a stumped.

Upvotes: 0

Views: 85

Answers (1)

Offnix
Offnix

Reputation: 27

Fixed my issue by just Deserializing the master class and then taking out the two subclasses afterwards. It's not what I wanted but it works

Upvotes: 1

Related Questions