So I have an object named Balance
that contains:
public class Balance
{
string balance1;
string balance2;
string currency;
}
and I'm trying to parse a JsonResult
object that is returned by a different function call into an instance of Balance
.
I've tried using JsonConvert.Serialize
and Deseralize<Balance>
, however, the object that I'm trying to parse into is set to null every time (ie balance1 = null
etc)
Any help would be much appreciated.
EDIT:
Below is the code I'm trying to parse. Also, I realized that the data access in JsonResult
is in a value called Data
and shows up as Data: { balance1: "800" balance2: "800" currency: "CAD"}
.
JsonResult result = admin.GetCompanyBalance(test.CustomerID, test.DevelopmentID);
string json = JsonConvert.SerializeObject(result);
Balance br = new Balance();
br = JsonConvert.DeserializeObject<Balance>(json);
JsonResult
look like? What doesBalanceResult
look like? You only showed usBalance
. – ForewomanGetCompanyBalance
actually look like? Is it actually serializing aBalance
object? Or something else? – Diaphragm