How to advoid Unknown field: MyJSON.number2019 Community Moderator ElectionHow to access the Organization “Currency Locale” ISO Locale code (NOT Currency code) in Apex/SOQLJSON and escaped double quoteJSON.deserialize not ignoring unknown properties.How can i concatenate json format using parseHow Can I Ignore Unknown Json Properties in ApexHow to parse XML data to JSON? How to deserialize XML to Apex class?Apex - How to parse json response to a mapHow to convert Json string with adminbooster and call a valueHow to read JSON that contains field that can have different typescapturing key and value of json as sobject field value

Customize circled numbers

On a tidally locked planet, would time be quantized?

Wrapping Cryptocurrencies for interoperability sake

Is camera lens focus an exact point or a range?

Constructing Group Divisible Designs - Algorithms?

Do the concepts of IP address and network interface not belong to the same layer?

How should I respond when I lied about my education and the company finds out through background check?

Is it possible to use .desktop files to open local pdf files on specific pages with a browser?

How do you respond to a colleague from another team when they're wrongly expecting that you'll help them?

Has Darkwing Duck ever met Scrooge McDuck?

When quoting, must I also copy hyphens used to divide words that continue on the next line?

What's the difference between 違法 and 不法?

How can Trident be so inexpensive? Will it orbit Triton or just do a (slow) flyby?

Folder comparison

Fly on a jet pack vs fly with a jet pack?

A social experiment. What is the worst that can happen?

Should I stop contributing to retirement accounts?

Query about absorption line spectra

Did arcade monitors have same pixel aspect ratio as TV sets?

Greco-Roman egalitarianism

Why does Async/Await work properly when the loop is inside the async function and not the other way around?

Can I sign legal documents with a smiley face?

What linear sensor for a keyboard?

Why is Arduino resetting while driving motors?



How to advoid Unknown field: MyJSON.number



2019 Community Moderator ElectionHow to access the Organization “Currency Locale” ISO Locale code (NOT Currency code) in Apex/SOQLJSON and escaped double quoteJSON.deserialize not ignoring unknown properties.How can i concatenate json format using parseHow Can I Ignore Unknown Json Properties in ApexHow to parse XML data to JSON? How to deserialize XML to Apex class?Apex - How to parse json response to a mapHow to convert Json string with adminbooster and call a valueHow to read JSON that contains field that can have different typescapturing key and value of json as sobject field value










2















I am having trouble with deserialising a jsonstring. In my debug I get the error System.JSONException: Unknown field: MyJSON.number. As number is a reserved field in salesforce I replace it with numberRep. I dont get why I get this error.



webservice



 @HttpPost
global static void createOpportunity()
RestRequest req = RestContext.request;
string a = req.requestBody.toString().remove('\');
system.debug('DEB1: '+ a);
MyJSON tClass = MyJSON.parse(a);
system.debug('DEB2: '+ tClass);
system.debug('DEB3: '+ tClass.billing.address_1 );
system.debug('DEB4: '+ tClass.cart_hash);



Class



public class MyJSON
public Integer id; //160
public Integer parent_id; //0
public String numberRep; //160
public String order_key; //wc_order_mGsqFiG3RfTGz
public String created_via; //admin
public String version; //3.5.7
public String status; //pending
public String currencyRep; //EUR
public String date_created; //2019-03-22T07:29:08
public String date_created_gmt; //2019-03-22T07:29:08
public String date_modified; //2019-03-22T07:29:14
public String date_modified_gmt; //2019-03-22T07:29:14
public String discount_total; //0.00
public String discount_tax; //0.00
public String shipping_total; //0.00
public String shipping_tax; //0.00
public String cart_tax; //0.00
public String total; //0.00
public String total_tax; //0.00
public boolean prices_include_tax;
public Integer customer_id; //0
public String customer_ip_address; //
public String customer_user_agent; //
public String customer_note; //
public cls_billing billing;
public cls_shipping shipping;
public String payment_method; //
public String payment_method_title; //
public String transaction_id; //
public cls_date_paid date_paid;
public cls_date_paid_gmt date_paid_gmt;
public cls_date_completed date_completed;
public cls_date_completed_gmt date_completed_gmt;
public String cart_hash; //
public cls_meta_data[] meta_data;
public cls_line_items[] line_items;
public cls_tax_lines[] tax_lines;
public cls_shipping_lines[] shipping_lines;
public cls_fee_lines[] fee_lines;
public cls_coupon_lines[] coupon_lines;
public cls_refunds[] refunds;
public class cls_billing
public String first_name; //
public String last_name; //
public String company; //
public String address_1; //
public String address_2; //
public String city; //
public String state; //
public String postcode; //
public String country; //
public String email; //
public String phone; //

public class cls_shipping
public String first_name; //
public String last_name; //
public String company; //
public String address_1; //
public String address_2; //
public String city; //
public String state; //
public String postcode; //
public String country; //

public class cls_date_paid

public class cls_date_paid_gmt

public class cls_date_completed

public class cls_date_completed_gmt

public class cls_meta_data

public class cls_line_items

public class cls_tax_lines

public class cls_shipping_lines

public class cls_fee_lines

public class cls_coupon_lines

public class cls_refunds

public static MyJSON parse(String json)
String jsonReplace = json.replace('"currency":', '"currencyRep":');
jsonReplace = jsonReplace.replace('"number"','"numberRep"');
return (MyJSON) System.JSON.deserializeStrict(json, MyJSON.class);




Jsonstring



"id":164,"parent_id":0,"number":"164","order_key":"wc_order_UeaNTHik3jec4","created_via":"admin","version":"3.5.7","status":"completed","currency":"EUR","date_created":"2019-03-22T08:37:18","date_created_gmt":"2019-03-22T08:37:18","date_modified":"2019-03-22T08:37:32","date_modified_gmt":"2019-03-22T08:37:32","discount_total":"0.00","discount_tax":"0.00","shipping_total":"0.00","shipping_tax":"0.00","cart_tax":"0.00","total":"0.00","total_tax":"0.00","prices_include_tax":false,"customer_id":0,"customer_ip_address":"","customer_user_agent":"","customer_note":"","billing":"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":"","email":"","phone":"","shipping":"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":"","payment_method":"","payment_method_title":"","transaction_id":"","date_paid":"2019-03-22","date_paid_gmt":"2019-03-22T08:37:32","date_completed":"2019-03-22T08:37:32","date_completed_gmt":"2019-03-22T08:37:32","cart_hash":"","meta_data":[],"line_items":[],"tax_lines":[],"shipping_lines":[],"fee_lines":[],"coupon_lines":[],"refunds":[]









share|improve this question
























  • N.B. Consider the convention currencyX and numberX instead of currencyRep, and numberRep

    – cropredy
    yesterday















2















I am having trouble with deserialising a jsonstring. In my debug I get the error System.JSONException: Unknown field: MyJSON.number. As number is a reserved field in salesforce I replace it with numberRep. I dont get why I get this error.



webservice



 @HttpPost
global static void createOpportunity()
RestRequest req = RestContext.request;
string a = req.requestBody.toString().remove('\');
system.debug('DEB1: '+ a);
MyJSON tClass = MyJSON.parse(a);
system.debug('DEB2: '+ tClass);
system.debug('DEB3: '+ tClass.billing.address_1 );
system.debug('DEB4: '+ tClass.cart_hash);



Class



public class MyJSON
public Integer id; //160
public Integer parent_id; //0
public String numberRep; //160
public String order_key; //wc_order_mGsqFiG3RfTGz
public String created_via; //admin
public String version; //3.5.7
public String status; //pending
public String currencyRep; //EUR
public String date_created; //2019-03-22T07:29:08
public String date_created_gmt; //2019-03-22T07:29:08
public String date_modified; //2019-03-22T07:29:14
public String date_modified_gmt; //2019-03-22T07:29:14
public String discount_total; //0.00
public String discount_tax; //0.00
public String shipping_total; //0.00
public String shipping_tax; //0.00
public String cart_tax; //0.00
public String total; //0.00
public String total_tax; //0.00
public boolean prices_include_tax;
public Integer customer_id; //0
public String customer_ip_address; //
public String customer_user_agent; //
public String customer_note; //
public cls_billing billing;
public cls_shipping shipping;
public String payment_method; //
public String payment_method_title; //
public String transaction_id; //
public cls_date_paid date_paid;
public cls_date_paid_gmt date_paid_gmt;
public cls_date_completed date_completed;
public cls_date_completed_gmt date_completed_gmt;
public String cart_hash; //
public cls_meta_data[] meta_data;
public cls_line_items[] line_items;
public cls_tax_lines[] tax_lines;
public cls_shipping_lines[] shipping_lines;
public cls_fee_lines[] fee_lines;
public cls_coupon_lines[] coupon_lines;
public cls_refunds[] refunds;
public class cls_billing
public String first_name; //
public String last_name; //
public String company; //
public String address_1; //
public String address_2; //
public String city; //
public String state; //
public String postcode; //
public String country; //
public String email; //
public String phone; //

public class cls_shipping
public String first_name; //
public String last_name; //
public String company; //
public String address_1; //
public String address_2; //
public String city; //
public String state; //
public String postcode; //
public String country; //

public class cls_date_paid

public class cls_date_paid_gmt

public class cls_date_completed

public class cls_date_completed_gmt

public class cls_meta_data

public class cls_line_items

public class cls_tax_lines

public class cls_shipping_lines

public class cls_fee_lines

public class cls_coupon_lines

public class cls_refunds

public static MyJSON parse(String json)
String jsonReplace = json.replace('"currency":', '"currencyRep":');
jsonReplace = jsonReplace.replace('"number"','"numberRep"');
return (MyJSON) System.JSON.deserializeStrict(json, MyJSON.class);




Jsonstring



"id":164,"parent_id":0,"number":"164","order_key":"wc_order_UeaNTHik3jec4","created_via":"admin","version":"3.5.7","status":"completed","currency":"EUR","date_created":"2019-03-22T08:37:18","date_created_gmt":"2019-03-22T08:37:18","date_modified":"2019-03-22T08:37:32","date_modified_gmt":"2019-03-22T08:37:32","discount_total":"0.00","discount_tax":"0.00","shipping_total":"0.00","shipping_tax":"0.00","cart_tax":"0.00","total":"0.00","total_tax":"0.00","prices_include_tax":false,"customer_id":0,"customer_ip_address":"","customer_user_agent":"","customer_note":"","billing":"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":"","email":"","phone":"","shipping":"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":"","payment_method":"","payment_method_title":"","transaction_id":"","date_paid":"2019-03-22","date_paid_gmt":"2019-03-22T08:37:32","date_completed":"2019-03-22T08:37:32","date_completed_gmt":"2019-03-22T08:37:32","cart_hash":"","meta_data":[],"line_items":[],"tax_lines":[],"shipping_lines":[],"fee_lines":[],"coupon_lines":[],"refunds":[]









share|improve this question
























  • N.B. Consider the convention currencyX and numberX instead of currencyRep, and numberRep

    – cropredy
    yesterday













2












2








2








I am having trouble with deserialising a jsonstring. In my debug I get the error System.JSONException: Unknown field: MyJSON.number. As number is a reserved field in salesforce I replace it with numberRep. I dont get why I get this error.



webservice



 @HttpPost
global static void createOpportunity()
RestRequest req = RestContext.request;
string a = req.requestBody.toString().remove('\');
system.debug('DEB1: '+ a);
MyJSON tClass = MyJSON.parse(a);
system.debug('DEB2: '+ tClass);
system.debug('DEB3: '+ tClass.billing.address_1 );
system.debug('DEB4: '+ tClass.cart_hash);



Class



public class MyJSON
public Integer id; //160
public Integer parent_id; //0
public String numberRep; //160
public String order_key; //wc_order_mGsqFiG3RfTGz
public String created_via; //admin
public String version; //3.5.7
public String status; //pending
public String currencyRep; //EUR
public String date_created; //2019-03-22T07:29:08
public String date_created_gmt; //2019-03-22T07:29:08
public String date_modified; //2019-03-22T07:29:14
public String date_modified_gmt; //2019-03-22T07:29:14
public String discount_total; //0.00
public String discount_tax; //0.00
public String shipping_total; //0.00
public String shipping_tax; //0.00
public String cart_tax; //0.00
public String total; //0.00
public String total_tax; //0.00
public boolean prices_include_tax;
public Integer customer_id; //0
public String customer_ip_address; //
public String customer_user_agent; //
public String customer_note; //
public cls_billing billing;
public cls_shipping shipping;
public String payment_method; //
public String payment_method_title; //
public String transaction_id; //
public cls_date_paid date_paid;
public cls_date_paid_gmt date_paid_gmt;
public cls_date_completed date_completed;
public cls_date_completed_gmt date_completed_gmt;
public String cart_hash; //
public cls_meta_data[] meta_data;
public cls_line_items[] line_items;
public cls_tax_lines[] tax_lines;
public cls_shipping_lines[] shipping_lines;
public cls_fee_lines[] fee_lines;
public cls_coupon_lines[] coupon_lines;
public cls_refunds[] refunds;
public class cls_billing
public String first_name; //
public String last_name; //
public String company; //
public String address_1; //
public String address_2; //
public String city; //
public String state; //
public String postcode; //
public String country; //
public String email; //
public String phone; //

public class cls_shipping
public String first_name; //
public String last_name; //
public String company; //
public String address_1; //
public String address_2; //
public String city; //
public String state; //
public String postcode; //
public String country; //

public class cls_date_paid

public class cls_date_paid_gmt

public class cls_date_completed

public class cls_date_completed_gmt

public class cls_meta_data

public class cls_line_items

public class cls_tax_lines

public class cls_shipping_lines

public class cls_fee_lines

public class cls_coupon_lines

public class cls_refunds

public static MyJSON parse(String json)
String jsonReplace = json.replace('"currency":', '"currencyRep":');
jsonReplace = jsonReplace.replace('"number"','"numberRep"');
return (MyJSON) System.JSON.deserializeStrict(json, MyJSON.class);




Jsonstring



"id":164,"parent_id":0,"number":"164","order_key":"wc_order_UeaNTHik3jec4","created_via":"admin","version":"3.5.7","status":"completed","currency":"EUR","date_created":"2019-03-22T08:37:18","date_created_gmt":"2019-03-22T08:37:18","date_modified":"2019-03-22T08:37:32","date_modified_gmt":"2019-03-22T08:37:32","discount_total":"0.00","discount_tax":"0.00","shipping_total":"0.00","shipping_tax":"0.00","cart_tax":"0.00","total":"0.00","total_tax":"0.00","prices_include_tax":false,"customer_id":0,"customer_ip_address":"","customer_user_agent":"","customer_note":"","billing":"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":"","email":"","phone":"","shipping":"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":"","payment_method":"","payment_method_title":"","transaction_id":"","date_paid":"2019-03-22","date_paid_gmt":"2019-03-22T08:37:32","date_completed":"2019-03-22T08:37:32","date_completed_gmt":"2019-03-22T08:37:32","cart_hash":"","meta_data":[],"line_items":[],"tax_lines":[],"shipping_lines":[],"fee_lines":[],"coupon_lines":[],"refunds":[]









share|improve this question
















I am having trouble with deserialising a jsonstring. In my debug I get the error System.JSONException: Unknown field: MyJSON.number. As number is a reserved field in salesforce I replace it with numberRep. I dont get why I get this error.



webservice



 @HttpPost
global static void createOpportunity()
RestRequest req = RestContext.request;
string a = req.requestBody.toString().remove('\');
system.debug('DEB1: '+ a);
MyJSON tClass = MyJSON.parse(a);
system.debug('DEB2: '+ tClass);
system.debug('DEB3: '+ tClass.billing.address_1 );
system.debug('DEB4: '+ tClass.cart_hash);



Class



public class MyJSON
public Integer id; //160
public Integer parent_id; //0
public String numberRep; //160
public String order_key; //wc_order_mGsqFiG3RfTGz
public String created_via; //admin
public String version; //3.5.7
public String status; //pending
public String currencyRep; //EUR
public String date_created; //2019-03-22T07:29:08
public String date_created_gmt; //2019-03-22T07:29:08
public String date_modified; //2019-03-22T07:29:14
public String date_modified_gmt; //2019-03-22T07:29:14
public String discount_total; //0.00
public String discount_tax; //0.00
public String shipping_total; //0.00
public String shipping_tax; //0.00
public String cart_tax; //0.00
public String total; //0.00
public String total_tax; //0.00
public boolean prices_include_tax;
public Integer customer_id; //0
public String customer_ip_address; //
public String customer_user_agent; //
public String customer_note; //
public cls_billing billing;
public cls_shipping shipping;
public String payment_method; //
public String payment_method_title; //
public String transaction_id; //
public cls_date_paid date_paid;
public cls_date_paid_gmt date_paid_gmt;
public cls_date_completed date_completed;
public cls_date_completed_gmt date_completed_gmt;
public String cart_hash; //
public cls_meta_data[] meta_data;
public cls_line_items[] line_items;
public cls_tax_lines[] tax_lines;
public cls_shipping_lines[] shipping_lines;
public cls_fee_lines[] fee_lines;
public cls_coupon_lines[] coupon_lines;
public cls_refunds[] refunds;
public class cls_billing
public String first_name; //
public String last_name; //
public String company; //
public String address_1; //
public String address_2; //
public String city; //
public String state; //
public String postcode; //
public String country; //
public String email; //
public String phone; //

public class cls_shipping
public String first_name; //
public String last_name; //
public String company; //
public String address_1; //
public String address_2; //
public String city; //
public String state; //
public String postcode; //
public String country; //

public class cls_date_paid

public class cls_date_paid_gmt

public class cls_date_completed

public class cls_date_completed_gmt

public class cls_meta_data

public class cls_line_items

public class cls_tax_lines

public class cls_shipping_lines

public class cls_fee_lines

public class cls_coupon_lines

public class cls_refunds

public static MyJSON parse(String json)
String jsonReplace = json.replace('"currency":', '"currencyRep":');
jsonReplace = jsonReplace.replace('"number"','"numberRep"');
return (MyJSON) System.JSON.deserializeStrict(json, MyJSON.class);




Jsonstring



"id":164,"parent_id":0,"number":"164","order_key":"wc_order_UeaNTHik3jec4","created_via":"admin","version":"3.5.7","status":"completed","currency":"EUR","date_created":"2019-03-22T08:37:18","date_created_gmt":"2019-03-22T08:37:18","date_modified":"2019-03-22T08:37:32","date_modified_gmt":"2019-03-22T08:37:32","discount_total":"0.00","discount_tax":"0.00","shipping_total":"0.00","shipping_tax":"0.00","cart_tax":"0.00","total":"0.00","total_tax":"0.00","prices_include_tax":false,"customer_id":0,"customer_ip_address":"","customer_user_agent":"","customer_note":"","billing":"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":"","email":"","phone":"","shipping":"first_name":"","last_name":"","company":"","address_1":"","address_2":"","city":"","state":"","postcode":"","country":"","payment_method":"","payment_method_title":"","transaction_id":"","date_paid":"2019-03-22","date_paid_gmt":"2019-03-22T08:37:32","date_completed":"2019-03-22T08:37:32","date_completed_gmt":"2019-03-22T08:37:32","cart_hash":"","meta_data":[],"line_items":[],"tax_lines":[],"shipping_lines":[],"fee_lines":[],"coupon_lines":[],"refunds":[]






apex json deserialize parser






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited yesterday







Thomas

















asked yesterday









ThomasThomas

709415




709415












  • N.B. Consider the convention currencyX and numberX instead of currencyRep, and numberRep

    – cropredy
    yesterday

















  • N.B. Consider the convention currencyX and numberX instead of currencyRep, and numberRep

    – cropredy
    yesterday
















N.B. Consider the convention currencyX and numberX instead of currencyRep, and numberRep

– cropredy
yesterday





N.B. Consider the convention currencyX and numberX instead of currencyRep, and numberRep

– cropredy
yesterday










1 Answer
1






active

oldest

votes


















3














Your class passes the wrong string to JSON.deserialize().



public static MyJSON parse(String json){
String jsonReplace = json.replace('"currency":', '"currencyRep":');
jsonReplace = jsonReplace.replace('"number"','"numberRep"');
return (MyJSON) System.JSON.deserializeStrict(json, MyJSON.class);


You're transforming the string, but then not using the transformed version. Change the final line to



 return (MyJSON) System.JSON.deserializeStrict(jsonReplace, MyJSON.class);





share|improve this answer























  • Kicking myself right now for not seeing this.

    – Derek F
    yesterday











  • @DavidReed Thanks! I feel really bad for missing this one.

    – Thomas
    yesterday










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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f255016%2fhow-to-advoid-unknown-field-myjson-number%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









3














Your class passes the wrong string to JSON.deserialize().



public static MyJSON parse(String json){
String jsonReplace = json.replace('"currency":', '"currencyRep":');
jsonReplace = jsonReplace.replace('"number"','"numberRep"');
return (MyJSON) System.JSON.deserializeStrict(json, MyJSON.class);


You're transforming the string, but then not using the transformed version. Change the final line to



 return (MyJSON) System.JSON.deserializeStrict(jsonReplace, MyJSON.class);





share|improve this answer























  • Kicking myself right now for not seeing this.

    – Derek F
    yesterday











  • @DavidReed Thanks! I feel really bad for missing this one.

    – Thomas
    yesterday















3














Your class passes the wrong string to JSON.deserialize().



public static MyJSON parse(String json){
String jsonReplace = json.replace('"currency":', '"currencyRep":');
jsonReplace = jsonReplace.replace('"number"','"numberRep"');
return (MyJSON) System.JSON.deserializeStrict(json, MyJSON.class);


You're transforming the string, but then not using the transformed version. Change the final line to



 return (MyJSON) System.JSON.deserializeStrict(jsonReplace, MyJSON.class);





share|improve this answer























  • Kicking myself right now for not seeing this.

    – Derek F
    yesterday











  • @DavidReed Thanks! I feel really bad for missing this one.

    – Thomas
    yesterday













3












3








3







Your class passes the wrong string to JSON.deserialize().



public static MyJSON parse(String json){
String jsonReplace = json.replace('"currency":', '"currencyRep":');
jsonReplace = jsonReplace.replace('"number"','"numberRep"');
return (MyJSON) System.JSON.deserializeStrict(json, MyJSON.class);


You're transforming the string, but then not using the transformed version. Change the final line to



 return (MyJSON) System.JSON.deserializeStrict(jsonReplace, MyJSON.class);





share|improve this answer













Your class passes the wrong string to JSON.deserialize().



public static MyJSON parse(String json){
String jsonReplace = json.replace('"currency":', '"currencyRep":');
jsonReplace = jsonReplace.replace('"number"','"numberRep"');
return (MyJSON) System.JSON.deserializeStrict(json, MyJSON.class);


You're transforming the string, but then not using the transformed version. Change the final line to



 return (MyJSON) System.JSON.deserializeStrict(jsonReplace, MyJSON.class);






share|improve this answer












share|improve this answer



share|improve this answer










answered yesterday









David ReedDavid Reed

37.9k82256




37.9k82256












  • Kicking myself right now for not seeing this.

    – Derek F
    yesterday











  • @DavidReed Thanks! I feel really bad for missing this one.

    – Thomas
    yesterday

















  • Kicking myself right now for not seeing this.

    – Derek F
    yesterday











  • @DavidReed Thanks! I feel really bad for missing this one.

    – Thomas
    yesterday
















Kicking myself right now for not seeing this.

– Derek F
yesterday





Kicking myself right now for not seeing this.

– Derek F
yesterday













@DavidReed Thanks! I feel really bad for missing this one.

– Thomas
yesterday





@DavidReed Thanks! I feel really bad for missing this one.

– Thomas
yesterday

















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f255016%2fhow-to-advoid-unknown-field-myjson-number%23new-answer', 'question_page');

);

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







Popular posts from this blog

Sum ergo cogito? 1 nng

三茅街道4182Guuntc Dn precexpngmageondP