How to advoid Unknown field: MyJSON.number The 2019 Stack Overflow Developer Survey Results Are InHow 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

What is the motivation for a law requiring 2 parties to consent for recording a conversation

Can a rogue use sneak attack with weapons that have the thrown property even if they are not thrown?

Is this app Icon Browser Safe/Legit?

How to notate time signature switching consistently every measure

Identify boardgame from Big movie

One word riddle: Vowel in the middle

Can you compress metal and what would be the consequences?

Is a "Democratic" Oligarchy-Style System Possible?

How to deal with fear of taking dependencies

What does ひと匙 mean in this manga and has it been used colloquially?

Aging parents with no investments

What did it mean to "align" a radio?

Is there any way to tell whether the shot is going to hit you or not?

Identify This Plant (Flower)

How come people say “Would of”?

Is an up-to-date browser secure on an out-of-date OS?

The difference between dialogue marks

What is the meaning of Triage in Cybersec world?

Is "plugging out" electronic devices an American expression?

Protecting Dualbooting Windows from dangerous code (like rm -rf)

For what reasons would an animal species NOT cross a *horizontal* land bridge?

Output the Arecibo Message

Can one be advised by a professor who is very far away?

What is the accessibility of a package's `Private` context variables?



How to advoid Unknown field: MyJSON.number



The 2019 Stack Overflow Developer Survey Results Are InHow 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



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








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
    Mar 23 at 18:36

















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
    Mar 23 at 18:36













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 Mar 23 at 14:13







Thomas

















asked Mar 23 at 13:49









ThomasThomas

738417




738417












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

    – cropredy
    Mar 23 at 18:36

















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

    – cropredy
    Mar 23 at 18:36
















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

– cropredy
Mar 23 at 18:36





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

– cropredy
Mar 23 at 18:36










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
    Mar 23 at 14:49











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

    – Thomas
    Mar 23 at 14:59











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
    Mar 23 at 14:49











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

    – Thomas
    Mar 23 at 14:59















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
    Mar 23 at 14:49











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

    – Thomas
    Mar 23 at 14:59













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 Mar 23 at 14:47









David ReedDavid Reed

39.3k82356




39.3k82356












  • Kicking myself right now for not seeing this.

    – Derek F
    Mar 23 at 14:49











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

    – Thomas
    Mar 23 at 14:59

















  • Kicking myself right now for not seeing this.

    – Derek F
    Mar 23 at 14:49











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

    – Thomas
    Mar 23 at 14:59
















Kicking myself right now for not seeing this.

– Derek F
Mar 23 at 14:49





Kicking myself right now for not seeing this.

– Derek F
Mar 23 at 14:49













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

– Thomas
Mar 23 at 14:59





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

– Thomas
Mar 23 at 14:59

















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

Moe incest case Sentencing See also References Navigation menu"'Australian Josef Fritzl' fathered four children by daughter""Small town recoils in horror at 'Australian Fritzl' incest case""Victorian rape allegations echo Fritzl case - Just In (Australian Broadcasting Corporation)""Incest father jailed for 22 years""'Australian Fritzl' sentenced to 22 years in prison for abusing daughter for three decades""RSJ v The Queen"

Who is our nearest planetary neighbor, on average?Santa Claus flies to the South PoleSeven Spheres of Unequal Mass, a weighing problem with a twistDescribe a large integerFast Mental Calculation of $7.5^7$Math in Space (without the help of celebrities)Find the value of $bigstar$: Puzzle 8 - InequalityWho drinks beer while running anyway?A Crucial DeliveryRanking And AverageHow long will my money last at roulette?

Daza language Contents Vocabulary Phonology References External links Navigation menudaza1242Daza"Dazaga"eeee178086576