Today I was working extracting information from a JSON object. I'm using jsonToken to navigate and get the values. When I have a JSON with 300 or less objects, I have no problem but when the JSON has more than 700 I always have the "Apex CPU limit exceeded" error.
After commenting a lot of code, here is what remains:
while(parser.nextToken() != null) {
if(parser.getCurrentToken() == JsonToken.FIELD_NAME) {
//fd.Name = parser.getText();
continue;
}
if(parser.getCurrentToken() == JsonToken.VALUE_STRING && fd.Name != null) {
//fd.Value = parser.getText();
//po.FieldAndValue.add(fd);
//fd = new FieldDetail();
continue;
}
if(parser.getCurrentToken() == JsonToken.START_OBJECT) {
//fd = new FieldDetail();
continue;
}
// Once we know end of object, we can start a new record.
if(parser.getCurrentToken() == JsonToken.END_OBJECT) {
//parcelLeads.add(generateParcelLead(po));
//parcelLeadJSONInfo.add(po);
//po = new ParsedObject();
continue;
}
}
As you see I'm doing nothing other than reading the JSON but still get the governor error. Is there any other way to extract the values? (map or parser.readValueAs cannot be used).
The Json is like this:
{
"2017-04-28_IL_Macoupin_MISO_DG":
[
{
"FID": "3",
"site_id": "IL_Site_16042",
"lomp_id": " " //, ... 64 more Keypairs here
}
]
}
In this example, there is only 1 record and 3 fields, there are 700 records and 67 fields in the real object.