function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Unable to use JSON.deseralize to deseralize an object which contains a list of another object



I am deseralizing the json string into an object which contains a list of another object, and getting this error:


Internal Salesforce Error: 17692538-4726 (1351590007) (1351590007) 

My code has been working up until this Wednesday. Was there any change that has been applied to cs2 env? This the test code I have:


public with sharing class JSONTest {
    public class InvoiceStatement {
        Long invoiceNumber;
        Datetime statementDate;
        Decimal totalPrice;
        public InvoiceStatement(Long i, Datetime dt, Decimal price)
            invoiceNumber = i;
            statementDate = dt;
            totalPrice = price;
    public class InvoiceStatementResponse {
        Integer errorCode;
        List<InvoiceStatement> statements;
        public InvoiceStatementResponse(Integer errorCode) {
            this.errorCode = errorCode;
            statements = new List<InvoiceStatement>();
    public static void SerializeRoundtrip() {
        Datetime dt =;
        // Create a few invoices.
        InvoiceStatement inv1 = new InvoiceStatement(1,Datetime.valueOf(dt),1000);
        InvoiceStatement inv2 = new InvoiceStatement(2,Datetime.valueOf(dt),500);
        // Add the invoices to a list.
        List<InvoiceStatement> invoices = new List<InvoiceStatement>();
         InvoiceStatementResponse resp = new InvoiceStatementResponse(0);
         resp.statements = invoices;
        String JSONString = JSON.serialize(resp);
        System.debug('Serialized list of invoices into JSON format: ' + JSONString);
        InvoiceStatementResponse dresp = (InvoiceStatementResponse)JSON.deserialize(JSONString, InvoiceStatementResponse.class);
        System.debug('dresp=' + dresp);
    private static testmethod void mytest() {


Any help is appreciated.



Paul Dyson.ax812Paul Dyson.ax812

We're seeing the same in a whole load of tests preventing us uploading a new version of our managed package


Okay, I see the problem.  Thanks for the report, we'll get this fixed ASAP.

It's a bug in the toString() of certain list types.  If you comment out the system.debug() method on line 44:


System.debug('dresp=' + dresp);


Your test should pass.


Thanks Rich. That error went away after commenting out the ebug statement. I also notice System.assertEquals returns the same internal error. The equals method probably has the same problem. It would be great if this can be fixed as well.

Dan Blackhall.ax1171Dan Blackhall.ax1171

I am having what I think is the same issue. I am trying to serialise a List of sobjects and their children. for example:



List<ParentObject__c> objects = [SELECT Id, Name, (SELECT Id, Name FROM ChildObjects__r) FROM ParentObject__c];

//Serialization is working correctly String json = System.JSON.serialize(objects);
//Deserialization is not List<ParentObject__c> deserialized = (List<ParentObject__c>)System.JSON.deserialize(json, List<ParentObject__c>.class);


If I try System.debug(deserialized) I get a JSONException system

If I omit the debug statement as suggested, I get a different exception Malformed JSON: Expected [ at the beginning of List/Set


Is there an eta on when this will be fixed?


This is a separate issue, specifically with parent/child sobject relationships and the list of lists that results from this particular type of query.

Thanks for the report, I'm looking into it now.


Okay, this fix should make it into the upcoming major release.

Dan Blackhall.ax1171Dan Blackhall.ax1171

Great, thanks for the update Rich


I am getting the same error: Content cannot be displayed: Malformed JSON: Expected '[' at the beginning of List/Set


Has this been fixed?