Alex Pineda
Alex Pineda

Reputation: 3029

Servicestack json serializer serializes to an empty object {}.

I was using the typed redis client for some replay tests just yesterday with a small DTO:

public class OrderDto
  {
  public int OrderNo;
  public double Subtotal;
  public double Total;
  }

This was working just fine with the serializer (which I assume defaults to a json serializer in the redis client). I would get something like this in redis:

"{\"OrderNo\":1,\"Subtotal\":10,\"Total\":11.37}"

Now when I expanded it to something like this:

public class CalcOrderDto
{
    public int OrderNo;
    public double MerchandiseQuantity;
    public double MerchandiseGross;
    public double MerchandiseAdjustment;
    public double MerchandiseTaxable;
    public double MerchandiseNet;
    public double MerchandiseTaxesTotal;

    public double ShippingQuantity;
    public double ShippingGross;
    public double ShippingAdjustment;
    public double ShippingTaxable;
    public double ShippingNet;
    public double ShippingTaxesTotal;

    public double FinalQuantity;
    public double FinalGross;
    public double FinalAdjustment;
    public double FinalTaxable;
    public double FinalNet;
    public double FinalTaxesTotal;
}

Now I only get this:

"{}"

My question is why !? This is a problem in another web service project as well, and so there I only serve up XML at the moment. Please help.

Upvotes: 1

Views: 418

Answers (1)

jeffgabhart
jeffgabhart

Reputation: 1127

Try using properties instead of fields.

Upvotes: 4

Related Questions