You need to sign in to do that
Don't have an account?
Mickle
JSON deserialization System.UnexpectedException: Salesforce System Error
I have some JSON that I'm trying to deserialize using System.JSON.deserialize and am getting an unexpected error.
Thinking the error was made by me, I found SimonF's & Pat Patterson's awesome tool to generate the required Apex Class, and the automagically generated unit test is still failing.
http://json2apex.herokuapp.com/makeApex
Here's the code, complete with unit test that is failing
// // Generated by JSON2Apex http://json2apex.herokuapp.com/ // public class JSON2Apex { public class Data { public List<List<Detections>> detections; } public class Detections { public String language; public Boolean isReliable; public Double confidence; } public Data data; public static JSON2Apex parse(String json) { return (JSON2Apex) System.JSON.deserialize(json, JSON2Apex.class); } static testMethod void testParse() { String json = '{'+ ' \"data\": {'+ ' \"detections\": ['+ ' ['+ ' {'+ ' \"language\": \"es\",'+ ' \"isReliable\": false,'+ ' \"confidence\": 0.6554622'+ ' }'+ ' ]'+ ' ]'+ ' }'+ '}'; JSON2Apex obj = parse(json); System.assert(obj != null); } }
Could this be a reserved word issue, or something having to do with inner classes? Any help would be appreciated.
Thanks,
Mike
It's not you, it's Force.com. A System.UnexpectedException is just that: an exception that was not expected to happen. Submit a case to support, and include the error number from one of your Run Tests output. I suspect that the cause is that a list of anonymously listed elements is not supported correctly. Best of luck with getting that fixed by support.
All Answers
What line you are getting the error ?
Here's the full debug log, the exception is being thrown as soon as I enter the parse method with the sample JSON.
25.0 APEX_CODE,FINE;APEX_PROFILING,FINE;DB,INFO;VALIDATION,INFO;WORKFLOW,FINEST
07:25:11.168 (168611000)|EXECUTION_STARTED
07:25:11.168 (168672000)|CODE_UNIT_STARTED|[EXTERNAL]|01pE00000010Ddm|JSON2Apex.testParse
07:25:11.169 (169166000)|METHOD_ENTRY|[1]|01pE00000010Ddm|JSON2Apex.JSON2Apex()
07:25:11.169 (169297000)|METHOD_EXIT|[1]|JSON2Apex
07:25:11.169 (169377000)|METHOD_ENTRY|[34]|01pE00000010Ddm|JSON2Apex.parse(String)
07:25:11.188 (188402000)|METHOD_EXIT|[34]|01pE00000010Ddm|JSON2Apex.parse(String)
07:25:11.188 (188531000)|FATAL_ERROR|System.UnexpectedException: Salesforce System Error: 1070267378-232 (-37663348) (-37663348)
(System Code)
Class.JSON2Apex.parse: line 17, column 1
Class.JSON2Apex.testParse: line 34, column 1
07:25:11.188 (188629000)|FATAL_ERROR|System.UnexpectedException: Salesforce System Error: 1070267378-232 (-37663348) (-37663348)
(System Code)
Class.JSON2Apex.parse: line 17, column 1
Class.JSON2Apex.testParse: line 34, column 1
07:25:11.190 (188654000)|CUMULATIVE_LIMIT_USAGE
07:25:11.190|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 0 out of 150
Number of DML rows: 0 out of 10000
Number of script statements: 3 out of 200000
Maximum heap size: 0 out of 6000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10
07:25:11.190|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
07:25:11.190|STATIC_VARIABLE_LIST|
String:_sfdcAdditionalCodeLocations:0
double:MIN_NORMAL:0
double:POSITIVE_INFINITY:0
long:serialVersionUID:0
Boolean:TRUE:0
double:MIN_VALUE:0
int:SIZE:0
int[]:sizeTable:0
char[]:DigitOnes:0
char[]:DigitTens:0
double:NaN:0
String:_sfdcAdditionalCodeLocations:0
double:NEGATIVE_INFINITY:0
int:MIN_VALUE:0
int:SIZE:0
double:MAX_VALUE:0
long:serialVersionUID:0
int:MAX_EXPONENT:0
int:MIN_EXPONENT:0
Boolean:FALSE:0
String:_sfdcSuppressedCodeLocations:0
int:MAX_VALUE:0
char[]:digits:0
long:serialVersionUID:0
String:__sfdcInnerTypes:0
String:_sfdcAdditionalCodeLocations:0
07:25:11.190|CUMULATIVE_LIMIT_USAGE_END
07:25:11.188 (188829000)|CODE_UNIT_FINISHED|JSON2Apex.testParse
07:25:11.188 (188839000)|EXECUTION_FINISHED
07:25:11.439|CUMULATIVE_PROFILING_BEGIN
07:25:11.439|CUMULATIVE_PROFILING|No profiling information for SOQL operations
07:25:11.439|CUMULATIVE_PROFILING|No profiling information for SOSL operations
07:25:11.439|CUMULATIVE_PROFILING|No profiling information for DML operations
07:25:11.439|CUMULATIVE_PROFILING|method invocations|
Class.JSON2Apex.testParse: line 34, column 1: public static JSON2Apex parse(String): executed 1 time in 19 ms
External entry point: static testMethod void testParse(): executed 1 time in 19 ms
Class.JSON2Apex.parse: line 17, column 1: global static Object deserialize(String, system.Type): executed 1 time in 18 ms
07:25:11.439|CUMULATIVE_PROFILING_END
It's not you, it's Force.com. A System.UnexpectedException is just that: an exception that was not expected to happen. Submit a case to support, and include the error number from one of your Run Tests output. I suspect that the cause is that a list of anonymously listed elements is not supported correctly. Best of luck with getting that fixed by support.
Thanks, sfdcfox.
That's what I figured, but wanted to know if were any known gotchas. I have a case logged with support and hopefully it can get resolved quickly.
:)
Hi Mike,
It does look like you've found a hole in our JSON support. I used the 'Create explicit parse code' option in JSON2Apex and edited the resulting code to come up with the following version that works:
Hope this is useful as a workaround. I'll bring this thread to the attention of the relevant R&D folks to increase the likelihood of a fix in a future release.
Cheers,
Pat