You need to sign in to do that
Don't have an account?

deserialize issue
Hello
I am deserialize json input but face error as follows.
I am facing an error as:Unknown field: My_Invoice_list.InvoiceWrapper.invoiceList
Error is in expression '{!deserialize}' in component <apex:commandButton> in page vf_invoicelist: (System Code)
Class.My_Invoice_list.deserialize: line 39, column 1
An unexpected error has occurred. Your solution provider has been notified. (System)
Below is the apex class code and vf page code.
I am not understanding how to display the line items.
divya
I am deserialize json input but face error as follows.
I am facing an error as:Unknown field: My_Invoice_list.InvoiceWrapper.invoiceList
Error is in expression '{!deserialize}' in component <apex:commandButton> in page vf_invoicelist: (System Code)
Class.My_Invoice_list.deserialize: line 39, column 1
An unexpected error has occurred. Your solution provider has been notified. (System)
Below is the apex class code and vf page code.
public class My_Invoice_list { public class InvoiceList { public Double totalPrice {get;set;} public String statementDate {get;set;} public List<LineItems> lineItems {get;set;} public Integer invoiceNumber {get;set;} } public class LineItems { public Double UnitPrice {get;set;} public Double Quantity {get;set;} public String ProductName {get;set;} } public class InvoiceWrapper { public list<InvoiceList> invoice_wrapper{get;set;} } public InvoiceWrapper invoice{get;set;} public void deserialize() { Http p = new Http(); HttpRequest request = new HttpRequest(); request.setEndPoint('https://docsample.herokuapp.com/jsonSample'); request.setHeader('Content-type', 'application/json'); request.setMethod('GET'); HttpResponse response=p.send(request); invoice=(InvoiceWrapper)JSON.deserializeStrict(response.getBody(),InvoiceWrapper.class); } }
<apex:page controller="My_Invoice_list"> <apex:form > <apex:pageBlock title="Deserialize JSON Resposne"> <apex:pageBlockSection> <apex:pageBlockSectionItem> <apex:commandButton value="submit" action="{!deserialize}" reRender="invoicetable"/> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> <apex:pageBlock> <apex:pageBlockTable value="{!invoice.invoice_wrapper}" var="inv" id="invoicetable"> <apex:column value="{!inv.totalPrice}" headerValue="TotalPrice" /> <apex:column value="{!inv.statementDate}" headerValue="statementDate" /> </apex:pageBlockTable> </apex:pageBlock> </apex:form> </apex:page>
I am not understanding how to display the line items.
divya
JSONDeserialize.cls
JSONDeserialize.vfp
All Answers
JSONDeserialize.cls
JSONDeserialize.vfp
still, I am getting the same bug
ur code works fine , but I am puzzled becaue its the same code I have executed , only class names change.
can u tell me how to display line items?
I made a change as follows:
The trick was the attribute "breakBefore"
<apex:column breakBefore="true"
colspan="2">
<apex:pageBlockTable value="{!inv.lineitems}"
var="line">
<apex:column value="{!line.unitPrice}"
headerValue="UnitPrice"/>
<apex:column value="{!line.quantity}"
headerValue="Quantity"/>
<apex:column value="{!line.productName}"
headerValue="productName"/>
</apex:pageBlockTable>
I got what I wanted.
Thanks for ur help.