JSON DeSerialization Help?Write a generic JSON-serializable Parameters class without hitting “Apex Type unsupported in JSON: Object”APEX ENUM Serialize to and Deserialize from JSONJSON and escaped double quotedeserializing JSON returns a null objectJSON deserialize into wrapper class errorsJSON String test classJSON: Cannot deserialize instance of date from VALUE_STRINGSystem.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set while deseriliasing json PayloadSalesforce REST JSON not getting serialized properly?How to deserialize my json result?
What dice to use in a game that revolves around triangles?
Lorentz invariance of Maxwell's equations in matter
Renting a house to a graduate student in my department
Why use steam instead of just hot air?
Thawing Glaciers return to hand interaction
How come mathematicians published in Annals of Eugenics?
How can Sam Wilson fulfill his future role?
My perfect evil overlord plan... or is it?
TeX Gyre Pagella Math Integral sign much too small
Compactness in normed vector spaces.
What is the radius of the circle in this problem?
Has everyone forgotten about wildfire?
Why do the Avengers care about returning these items in Endgame?
Was the Highlands Ranch shooting the 115th mass shooting in the US in 2019
"Estrontium" on poster
How can I make parentheses stick to formula?
How can I test a shell script in a "safe environment" to avoid harm to my computer?
How to explain intravenous drug abuse to a 6-year-old?
Not taking the bishop by the knight, why?
What is a good way to allow only one non null field in an object
Identity of a supposed anonymous referee revealed through "Description" of the report
How did Captain Marvel know where to find these characters?
Rusty Chain and back cassette – Replace or Repair?
Names of the Six Tastes
JSON DeSerialization Help?
Write a generic JSON-serializable Parameters class without hitting “Apex Type unsupported in JSON: Object”APEX ENUM Serialize to and Deserialize from JSONJSON and escaped double quotedeserializing JSON returns a null objectJSON deserialize into wrapper class errorsJSON String test classJSON: Cannot deserialize instance of date from VALUE_STRINGSystem.JSONException: Malformed JSON: Expected '[' at the beginning of List/Set while deseriliasing json PayloadSalesforce REST JSON not getting serialized properly?How to deserialize my json result?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I am currently working on an integration with other systems and I have the JSON coming back in the below format.
"searchDocumentsResponse":
"documentsIndexInfo": [
"contentElementsInfo":
"fileName": "test.pdf",
"fileSize": 1010694,
"indexNumber": 0,
"mimeType": "application/pdf"
,
"guid": "123456789-1234-1234-1234-92393300000",
"majorVersion": 1,
"minorVersion": 0,
"objectStore": "09876543212-1234-4B53-8CC5-469444E92456",
"pathName": "",
"properties": [
"multiValue": false,
"name": "Document_Type",
"type": "STRING",
"value": "TEST"
,
"multiValue": false,
"name": "ScanTMSTMP",
"type": "DATE",
"value": "5/16/1920"
,
"multiValue": false,
"name": "f_DocNumber",
"type": "STRING",
"value": ""
,
"multiValue": false,
"name": "MimeType",
"type": "STRING",
"value": "application/pdf"
,
"multiValue": false,
"name": "DateCreated",
"type": "DATE",
"value": "5/31/2018"
]
],
"numDocObjectsFound": 1,
"numDocObjectsReturned": 1,
"responseStatus":
"code": "OK",
"message": ""
,
"startingDocObject": 0
And I am trying to parse the response like below:
public class DocumentRetrievalResponse
public SearchDocumentsResponse searchDocumentsResponse get;set;
public cecDocumentRetrievalResponse()
public class SearchDocumentsResponse
public String numDocObjectsFound get;set;
public String numDocObjectsReturned get;set;
public ResponseStatus responseStatus get;set;
public String startingDocObject get;set;
public List<DocumentsIndexInfo> documentsIndexInfo get;set; documentsIndexInfo = new List<DocumentsIndexInfo>();
public SearchDocumentsResponse()
public class ResponseStatus
public String code get;set;
public String messageget;set;
public ResponseStatus()
public class DocumentsIndexInfo
public String guidget;set; guid = null;
public Integer majorVersionget;set; majorVersion = 0;
public Integer minorVersionget;set;minorVersion = 0;
public String objectStoreget;set;objectStore = null;
public String pathNameget;set; pathName = null;
public ContentElementsInfo contentElementsInfo get;set;
public List<Properties> propertiesget;set; properties = new List<Properties>();
public class ContentElementsInfo
public String fileNameget;set; fileName = null;
public Integer fileSizeget;set; fileSize = 0;
public Integer indexNumberget;set; indexNumber = 0;
public String mimeTypeget;set;mimeType = null;
public class Properties
public String name get;set;
public String value get;set;
public String type get;set;
public String multiValue get;set; multiValue = 'false';
And to deserialize, I have the below lines:
System.Type resultType = System.Type.forName('DocumentRetrievalResponse');
DocumentRetrievalResponse deserializeResults =
(DocumentRetrievalResponse)JSON.deserialize(result, resultType);
When I run it, I get the JSON Exception as below. I might be overthinking and missing something here. Any help on this is appreciated.
FATAL_ERROR System.JSONException: Expected DocumentRetrievalResponse.ContentElementsInfo but found [line:1, column:2444]
PS: if I comment the declaration public ContentElementsInfo contentElementsInfo get;set;
, the deserialize happens fine but without ContentElementsInfo
.
apex json deserialize parser
add a comment |
I am currently working on an integration with other systems and I have the JSON coming back in the below format.
"searchDocumentsResponse":
"documentsIndexInfo": [
"contentElementsInfo":
"fileName": "test.pdf",
"fileSize": 1010694,
"indexNumber": 0,
"mimeType": "application/pdf"
,
"guid": "123456789-1234-1234-1234-92393300000",
"majorVersion": 1,
"minorVersion": 0,
"objectStore": "09876543212-1234-4B53-8CC5-469444E92456",
"pathName": "",
"properties": [
"multiValue": false,
"name": "Document_Type",
"type": "STRING",
"value": "TEST"
,
"multiValue": false,
"name": "ScanTMSTMP",
"type": "DATE",
"value": "5/16/1920"
,
"multiValue": false,
"name": "f_DocNumber",
"type": "STRING",
"value": ""
,
"multiValue": false,
"name": "MimeType",
"type": "STRING",
"value": "application/pdf"
,
"multiValue": false,
"name": "DateCreated",
"type": "DATE",
"value": "5/31/2018"
]
],
"numDocObjectsFound": 1,
"numDocObjectsReturned": 1,
"responseStatus":
"code": "OK",
"message": ""
,
"startingDocObject": 0
And I am trying to parse the response like below:
public class DocumentRetrievalResponse
public SearchDocumentsResponse searchDocumentsResponse get;set;
public cecDocumentRetrievalResponse()
public class SearchDocumentsResponse
public String numDocObjectsFound get;set;
public String numDocObjectsReturned get;set;
public ResponseStatus responseStatus get;set;
public String startingDocObject get;set;
public List<DocumentsIndexInfo> documentsIndexInfo get;set; documentsIndexInfo = new List<DocumentsIndexInfo>();
public SearchDocumentsResponse()
public class ResponseStatus
public String code get;set;
public String messageget;set;
public ResponseStatus()
public class DocumentsIndexInfo
public String guidget;set; guid = null;
public Integer majorVersionget;set; majorVersion = 0;
public Integer minorVersionget;set;minorVersion = 0;
public String objectStoreget;set;objectStore = null;
public String pathNameget;set; pathName = null;
public ContentElementsInfo contentElementsInfo get;set;
public List<Properties> propertiesget;set; properties = new List<Properties>();
public class ContentElementsInfo
public String fileNameget;set; fileName = null;
public Integer fileSizeget;set; fileSize = 0;
public Integer indexNumberget;set; indexNumber = 0;
public String mimeTypeget;set;mimeType = null;
public class Properties
public String name get;set;
public String value get;set;
public String type get;set;
public String multiValue get;set; multiValue = 'false';
And to deserialize, I have the below lines:
System.Type resultType = System.Type.forName('DocumentRetrievalResponse');
DocumentRetrievalResponse deserializeResults =
(DocumentRetrievalResponse)JSON.deserialize(result, resultType);
When I run it, I get the JSON Exception as below. I might be overthinking and missing something here. Any help on this is appreciated.
FATAL_ERROR System.JSONException: Expected DocumentRetrievalResponse.ContentElementsInfo but found [line:1, column:2444]
PS: if I comment the declaration public ContentElementsInfo contentElementsInfo get;set;
, the deserialize happens fine but without ContentElementsInfo
.
apex json deserialize parser
1
Unless its a typo, you have an invalid constructor herepublic cecDocumentRetrievalResponse()
. Is this the only error you are getting? With a minimal code, if reproduced, I don't see an issue here.
– Jayant Das
3 hours ago
Your model syntax is awkward, as you have multiple instance initializers (e.g.documentsIndexInfo = new List<DocumentsIndexInfo>();
) in several of your class definitions. They do nothing in the context of deserialization and can simply be removed. In addition, the documentation recommends you reserve use of initializers for complex logic.
– Adrian Larson♦
3 hours ago
N.B. attributemultiValue
sb declared as Boolean;majorVersion
andminorVersion
as Integer
– cropredy
3 hours ago
add a comment |
I am currently working on an integration with other systems and I have the JSON coming back in the below format.
"searchDocumentsResponse":
"documentsIndexInfo": [
"contentElementsInfo":
"fileName": "test.pdf",
"fileSize": 1010694,
"indexNumber": 0,
"mimeType": "application/pdf"
,
"guid": "123456789-1234-1234-1234-92393300000",
"majorVersion": 1,
"minorVersion": 0,
"objectStore": "09876543212-1234-4B53-8CC5-469444E92456",
"pathName": "",
"properties": [
"multiValue": false,
"name": "Document_Type",
"type": "STRING",
"value": "TEST"
,
"multiValue": false,
"name": "ScanTMSTMP",
"type": "DATE",
"value": "5/16/1920"
,
"multiValue": false,
"name": "f_DocNumber",
"type": "STRING",
"value": ""
,
"multiValue": false,
"name": "MimeType",
"type": "STRING",
"value": "application/pdf"
,
"multiValue": false,
"name": "DateCreated",
"type": "DATE",
"value": "5/31/2018"
]
],
"numDocObjectsFound": 1,
"numDocObjectsReturned": 1,
"responseStatus":
"code": "OK",
"message": ""
,
"startingDocObject": 0
And I am trying to parse the response like below:
public class DocumentRetrievalResponse
public SearchDocumentsResponse searchDocumentsResponse get;set;
public cecDocumentRetrievalResponse()
public class SearchDocumentsResponse
public String numDocObjectsFound get;set;
public String numDocObjectsReturned get;set;
public ResponseStatus responseStatus get;set;
public String startingDocObject get;set;
public List<DocumentsIndexInfo> documentsIndexInfo get;set; documentsIndexInfo = new List<DocumentsIndexInfo>();
public SearchDocumentsResponse()
public class ResponseStatus
public String code get;set;
public String messageget;set;
public ResponseStatus()
public class DocumentsIndexInfo
public String guidget;set; guid = null;
public Integer majorVersionget;set; majorVersion = 0;
public Integer minorVersionget;set;minorVersion = 0;
public String objectStoreget;set;objectStore = null;
public String pathNameget;set; pathName = null;
public ContentElementsInfo contentElementsInfo get;set;
public List<Properties> propertiesget;set; properties = new List<Properties>();
public class ContentElementsInfo
public String fileNameget;set; fileName = null;
public Integer fileSizeget;set; fileSize = 0;
public Integer indexNumberget;set; indexNumber = 0;
public String mimeTypeget;set;mimeType = null;
public class Properties
public String name get;set;
public String value get;set;
public String type get;set;
public String multiValue get;set; multiValue = 'false';
And to deserialize, I have the below lines:
System.Type resultType = System.Type.forName('DocumentRetrievalResponse');
DocumentRetrievalResponse deserializeResults =
(DocumentRetrievalResponse)JSON.deserialize(result, resultType);
When I run it, I get the JSON Exception as below. I might be overthinking and missing something here. Any help on this is appreciated.
FATAL_ERROR System.JSONException: Expected DocumentRetrievalResponse.ContentElementsInfo but found [line:1, column:2444]
PS: if I comment the declaration public ContentElementsInfo contentElementsInfo get;set;
, the deserialize happens fine but without ContentElementsInfo
.
apex json deserialize parser
I am currently working on an integration with other systems and I have the JSON coming back in the below format.
"searchDocumentsResponse":
"documentsIndexInfo": [
"contentElementsInfo":
"fileName": "test.pdf",
"fileSize": 1010694,
"indexNumber": 0,
"mimeType": "application/pdf"
,
"guid": "123456789-1234-1234-1234-92393300000",
"majorVersion": 1,
"minorVersion": 0,
"objectStore": "09876543212-1234-4B53-8CC5-469444E92456",
"pathName": "",
"properties": [
"multiValue": false,
"name": "Document_Type",
"type": "STRING",
"value": "TEST"
,
"multiValue": false,
"name": "ScanTMSTMP",
"type": "DATE",
"value": "5/16/1920"
,
"multiValue": false,
"name": "f_DocNumber",
"type": "STRING",
"value": ""
,
"multiValue": false,
"name": "MimeType",
"type": "STRING",
"value": "application/pdf"
,
"multiValue": false,
"name": "DateCreated",
"type": "DATE",
"value": "5/31/2018"
]
],
"numDocObjectsFound": 1,
"numDocObjectsReturned": 1,
"responseStatus":
"code": "OK",
"message": ""
,
"startingDocObject": 0
And I am trying to parse the response like below:
public class DocumentRetrievalResponse
public SearchDocumentsResponse searchDocumentsResponse get;set;
public cecDocumentRetrievalResponse()
public class SearchDocumentsResponse
public String numDocObjectsFound get;set;
public String numDocObjectsReturned get;set;
public ResponseStatus responseStatus get;set;
public String startingDocObject get;set;
public List<DocumentsIndexInfo> documentsIndexInfo get;set; documentsIndexInfo = new List<DocumentsIndexInfo>();
public SearchDocumentsResponse()
public class ResponseStatus
public String code get;set;
public String messageget;set;
public ResponseStatus()
public class DocumentsIndexInfo
public String guidget;set; guid = null;
public Integer majorVersionget;set; majorVersion = 0;
public Integer minorVersionget;set;minorVersion = 0;
public String objectStoreget;set;objectStore = null;
public String pathNameget;set; pathName = null;
public ContentElementsInfo contentElementsInfo get;set;
public List<Properties> propertiesget;set; properties = new List<Properties>();
public class ContentElementsInfo
public String fileNameget;set; fileName = null;
public Integer fileSizeget;set; fileSize = 0;
public Integer indexNumberget;set; indexNumber = 0;
public String mimeTypeget;set;mimeType = null;
public class Properties
public String name get;set;
public String value get;set;
public String type get;set;
public String multiValue get;set; multiValue = 'false';
And to deserialize, I have the below lines:
System.Type resultType = System.Type.forName('DocumentRetrievalResponse');
DocumentRetrievalResponse deserializeResults =
(DocumentRetrievalResponse)JSON.deserialize(result, resultType);
When I run it, I get the JSON Exception as below. I might be overthinking and missing something here. Any help on this is appreciated.
FATAL_ERROR System.JSONException: Expected DocumentRetrievalResponse.ContentElementsInfo but found [line:1, column:2444]
PS: if I comment the declaration public ContentElementsInfo contentElementsInfo get;set;
, the deserialize happens fine but without ContentElementsInfo
.
apex json deserialize parser
apex json deserialize parser
edited 3 hours ago
Adrian Larson♦
112k19123262
112k19123262
asked 4 hours ago
RajeshRajesh
3116
3116
1
Unless its a typo, you have an invalid constructor herepublic cecDocumentRetrievalResponse()
. Is this the only error you are getting? With a minimal code, if reproduced, I don't see an issue here.
– Jayant Das
3 hours ago
Your model syntax is awkward, as you have multiple instance initializers (e.g.documentsIndexInfo = new List<DocumentsIndexInfo>();
) in several of your class definitions. They do nothing in the context of deserialization and can simply be removed. In addition, the documentation recommends you reserve use of initializers for complex logic.
– Adrian Larson♦
3 hours ago
N.B. attributemultiValue
sb declared as Boolean;majorVersion
andminorVersion
as Integer
– cropredy
3 hours ago
add a comment |
1
Unless its a typo, you have an invalid constructor herepublic cecDocumentRetrievalResponse()
. Is this the only error you are getting? With a minimal code, if reproduced, I don't see an issue here.
– Jayant Das
3 hours ago
Your model syntax is awkward, as you have multiple instance initializers (e.g.documentsIndexInfo = new List<DocumentsIndexInfo>();
) in several of your class definitions. They do nothing in the context of deserialization and can simply be removed. In addition, the documentation recommends you reserve use of initializers for complex logic.
– Adrian Larson♦
3 hours ago
N.B. attributemultiValue
sb declared as Boolean;majorVersion
andminorVersion
as Integer
– cropredy
3 hours ago
1
1
Unless its a typo, you have an invalid constructor here
public cecDocumentRetrievalResponse()
. Is this the only error you are getting? With a minimal code, if reproduced, I don't see an issue here.– Jayant Das
3 hours ago
Unless its a typo, you have an invalid constructor here
public cecDocumentRetrievalResponse()
. Is this the only error you are getting? With a minimal code, if reproduced, I don't see an issue here.– Jayant Das
3 hours ago
Your model syntax is awkward, as you have multiple instance initializers (e.g.
documentsIndexInfo = new List<DocumentsIndexInfo>();
) in several of your class definitions. They do nothing in the context of deserialization and can simply be removed. In addition, the documentation recommends you reserve use of initializers for complex logic.– Adrian Larson♦
3 hours ago
Your model syntax is awkward, as you have multiple instance initializers (e.g.
documentsIndexInfo = new List<DocumentsIndexInfo>();
) in several of your class definitions. They do nothing in the context of deserialization and can simply be removed. In addition, the documentation recommends you reserve use of initializers for complex logic.– Adrian Larson♦
3 hours ago
N.B. attribute
multiValue
sb declared as Boolean; majorVersion
and minorVersion
as Integer– cropredy
3 hours ago
N.B. attribute
multiValue
sb declared as Boolean; majorVersion
and minorVersion
as Integer– cropredy
3 hours ago
add a comment |
1 Answer
1
active
oldest
votes
You seem to have a typo in your class.
cecDocumentRetrievalResponse()
should be
DocumentRetrievalResponse()
If I use your same DocumentRetrievalResponse class, remove the cec and use your JSON I can run your lines and it works for me. I made no changes to your code.
String result = '"searchDocumentsResponse": "documentsIndexInfo": ["contentElementsInfo": "fileName": "test.pdf","fileSize": 1010694,"indexNumber": 0,"mimeType": "application/pdf","guid": "123456789-1234-1234-1234-92393300000","majorVersion": 1,"minorVersion": 0,"objectStore": "09876543212-1234-4B53-8CC5-469444E92456","pathName": "","properties": ["multiValue": false,"name": "Document_Type","type": "STRING","value": "TEST","multiValue": false,"name": "ScanTMSTMP","type": "DATE","value": "5/16/1920","multiValue": false,"name": "f_DocNumber","type": "STRING","value": "","multiValue": false,"name": "MimeType","type": "STRING","value": "application/pdf","multiValue": false,"name": "DateCreated","type": "DATE","value": "5/31/2018"] ],"numDocObjectsFound": 1,"numDocObjectsReturned": 1,"responseStatus": "code": "OK","message": "","startingDocObject": 0';
System.Type resultType = System.Type.forName('DocumentRetrievalResponse');
DocumentRetrievalResponse deserializeResults = (DocumentRetrievalResponse)JSON.deserialize(result, resultType);
System.debug('deserializeResults ' + deserializeResults.searchDocumentsResponse.documentsIndexInfo[0].contentElementsInfo.fileName);
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f261700%2fjson-deserialization-help%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You seem to have a typo in your class.
cecDocumentRetrievalResponse()
should be
DocumentRetrievalResponse()
If I use your same DocumentRetrievalResponse class, remove the cec and use your JSON I can run your lines and it works for me. I made no changes to your code.
String result = '"searchDocumentsResponse": "documentsIndexInfo": ["contentElementsInfo": "fileName": "test.pdf","fileSize": 1010694,"indexNumber": 0,"mimeType": "application/pdf","guid": "123456789-1234-1234-1234-92393300000","majorVersion": 1,"minorVersion": 0,"objectStore": "09876543212-1234-4B53-8CC5-469444E92456","pathName": "","properties": ["multiValue": false,"name": "Document_Type","type": "STRING","value": "TEST","multiValue": false,"name": "ScanTMSTMP","type": "DATE","value": "5/16/1920","multiValue": false,"name": "f_DocNumber","type": "STRING","value": "","multiValue": false,"name": "MimeType","type": "STRING","value": "application/pdf","multiValue": false,"name": "DateCreated","type": "DATE","value": "5/31/2018"] ],"numDocObjectsFound": 1,"numDocObjectsReturned": 1,"responseStatus": "code": "OK","message": "","startingDocObject": 0';
System.Type resultType = System.Type.forName('DocumentRetrievalResponse');
DocumentRetrievalResponse deserializeResults = (DocumentRetrievalResponse)JSON.deserialize(result, resultType);
System.debug('deserializeResults ' + deserializeResults.searchDocumentsResponse.documentsIndexInfo[0].contentElementsInfo.fileName);
add a comment |
You seem to have a typo in your class.
cecDocumentRetrievalResponse()
should be
DocumentRetrievalResponse()
If I use your same DocumentRetrievalResponse class, remove the cec and use your JSON I can run your lines and it works for me. I made no changes to your code.
String result = '"searchDocumentsResponse": "documentsIndexInfo": ["contentElementsInfo": "fileName": "test.pdf","fileSize": 1010694,"indexNumber": 0,"mimeType": "application/pdf","guid": "123456789-1234-1234-1234-92393300000","majorVersion": 1,"minorVersion": 0,"objectStore": "09876543212-1234-4B53-8CC5-469444E92456","pathName": "","properties": ["multiValue": false,"name": "Document_Type","type": "STRING","value": "TEST","multiValue": false,"name": "ScanTMSTMP","type": "DATE","value": "5/16/1920","multiValue": false,"name": "f_DocNumber","type": "STRING","value": "","multiValue": false,"name": "MimeType","type": "STRING","value": "application/pdf","multiValue": false,"name": "DateCreated","type": "DATE","value": "5/31/2018"] ],"numDocObjectsFound": 1,"numDocObjectsReturned": 1,"responseStatus": "code": "OK","message": "","startingDocObject": 0';
System.Type resultType = System.Type.forName('DocumentRetrievalResponse');
DocumentRetrievalResponse deserializeResults = (DocumentRetrievalResponse)JSON.deserialize(result, resultType);
System.debug('deserializeResults ' + deserializeResults.searchDocumentsResponse.documentsIndexInfo[0].contentElementsInfo.fileName);
add a comment |
You seem to have a typo in your class.
cecDocumentRetrievalResponse()
should be
DocumentRetrievalResponse()
If I use your same DocumentRetrievalResponse class, remove the cec and use your JSON I can run your lines and it works for me. I made no changes to your code.
String result = '"searchDocumentsResponse": "documentsIndexInfo": ["contentElementsInfo": "fileName": "test.pdf","fileSize": 1010694,"indexNumber": 0,"mimeType": "application/pdf","guid": "123456789-1234-1234-1234-92393300000","majorVersion": 1,"minorVersion": 0,"objectStore": "09876543212-1234-4B53-8CC5-469444E92456","pathName": "","properties": ["multiValue": false,"name": "Document_Type","type": "STRING","value": "TEST","multiValue": false,"name": "ScanTMSTMP","type": "DATE","value": "5/16/1920","multiValue": false,"name": "f_DocNumber","type": "STRING","value": "","multiValue": false,"name": "MimeType","type": "STRING","value": "application/pdf","multiValue": false,"name": "DateCreated","type": "DATE","value": "5/31/2018"] ],"numDocObjectsFound": 1,"numDocObjectsReturned": 1,"responseStatus": "code": "OK","message": "","startingDocObject": 0';
System.Type resultType = System.Type.forName('DocumentRetrievalResponse');
DocumentRetrievalResponse deserializeResults = (DocumentRetrievalResponse)JSON.deserialize(result, resultType);
System.debug('deserializeResults ' + deserializeResults.searchDocumentsResponse.documentsIndexInfo[0].contentElementsInfo.fileName);
You seem to have a typo in your class.
cecDocumentRetrievalResponse()
should be
DocumentRetrievalResponse()
If I use your same DocumentRetrievalResponse class, remove the cec and use your JSON I can run your lines and it works for me. I made no changes to your code.
String result = '"searchDocumentsResponse": "documentsIndexInfo": ["contentElementsInfo": "fileName": "test.pdf","fileSize": 1010694,"indexNumber": 0,"mimeType": "application/pdf","guid": "123456789-1234-1234-1234-92393300000","majorVersion": 1,"minorVersion": 0,"objectStore": "09876543212-1234-4B53-8CC5-469444E92456","pathName": "","properties": ["multiValue": false,"name": "Document_Type","type": "STRING","value": "TEST","multiValue": false,"name": "ScanTMSTMP","type": "DATE","value": "5/16/1920","multiValue": false,"name": "f_DocNumber","type": "STRING","value": "","multiValue": false,"name": "MimeType","type": "STRING","value": "application/pdf","multiValue": false,"name": "DateCreated","type": "DATE","value": "5/31/2018"] ],"numDocObjectsFound": 1,"numDocObjectsReturned": 1,"responseStatus": "code": "OK","message": "","startingDocObject": 0';
System.Type resultType = System.Type.forName('DocumentRetrievalResponse');
DocumentRetrievalResponse deserializeResults = (DocumentRetrievalResponse)JSON.deserialize(result, resultType);
System.debug('deserializeResults ' + deserializeResults.searchDocumentsResponse.documentsIndexInfo[0].contentElementsInfo.fileName);
answered 3 hours ago
TadTad
1359
1359
add a comment |
add a comment |
Thanks for contributing an answer to Salesforce Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f261700%2fjson-deserialization-help%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
Unless its a typo, you have an invalid constructor here
public cecDocumentRetrievalResponse()
. Is this the only error you are getting? With a minimal code, if reproduced, I don't see an issue here.– Jayant Das
3 hours ago
Your model syntax is awkward, as you have multiple instance initializers (e.g.
documentsIndexInfo = new List<DocumentsIndexInfo>();
) in several of your class definitions. They do nothing in the context of deserialization and can simply be removed. In addition, the documentation recommends you reserve use of initializers for complex logic.– Adrian Larson♦
3 hours ago
N.B. attribute
multiValue
sb declared as Boolean;majorVersion
andminorVersion
as Integer– cropredy
3 hours ago