How to advoid Unknown field: MyJSON.numberHow 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

Why is python script running in background consuming 100 % CPU?

Can an airline pilot be prosecuted for killing an unruly passenger who could not be physically restrained?

Working hours and productivity expectations for game artists and programmers

Can you use Windows 10 "find my PC" location feature without a Microsoft login?

How was the blinking terminal cursor invented?

Why aren't satellites disintegrated even though they orbit earth within earth's Roche Limits?

How to convince boss to spend notice period on documentation instead of new projects

Service 'iisadmin' (iisadmin) failed to start

Can a problematic AL DM/organizer prevent me from running a separatate AL-legal game at the same store?

Print characters from list with a For-loop

Bash Read: Reading comma separated list, last element is missed

Was murdering a slave illegal in American slavery, and if so, what punishments were given for it?

Gambler's Fallacy Dice

Does the Aboleth have expertise in history and perception?

Addressing an email

How come Arya Stark wasn't hurt by this in Game of Thrones Season 8 Episode 5?

What were the "pills" that were added to solid waste in Apollo 7?

Was Tyrion always a poor strategist?

Why won't the U.S. be a signatory nation of The United Nations Convention on the Law of the Sea?

Can't think of a good word or term to describe not feeling or thinking

Why are Marine Le Pen's possible connections with Steve Bannon something worth investigating?

On a piano, are the effects of holding notes and the sustain pedal the same for a single chord?

How do you cope with rejection?

Latin words remembered from high school 50 years ago



How to advoid Unknown field: MyJSON.number


How 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

768420




768420












  • 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

42.6k82463




42.6k82463












  • 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

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해