1

I am working on a lwc. I am passing a array of json objects into a apex method. The parameter for the apex method is a List<Work_Items> where work items is a SF object. At run time apex converts the json to a list of work items but how to the sobjects field types convert. I have a flag field and need to check it. Will the json value for the field be converted to a bool on the sobject or will it be a string?

1 Answer 1

2

The types are all pretty much what you'd expect from JSON. Boolean values will be true/false (not String values). What follow is, I believe, what each type will be converted to, based on my experience. I haven't tested all of these, though, so a few may be incorrect; please feel free to let me know if any of these are wrong.

Apex Schema.DisplayType JavaScript
address Object of Fields e.g. { street: String, city: String, ... }
any String
base64 String
Boolean Boolean true or false
Combobox String
Currency Number
DataCategoryGroupReference String
Date String
DateTime String
Double Number
Email String
EncryptedString String
ID String
Integer Number
Location Object of fields { lat: Number, long: Number, ... }
Long Number
MultiPicklist String, semi-colon separated
Percent Number
Phone String
Picklist String
Reference Id or Object of fields e.g. { name: String, ... }
String String
TextArea String
Time String
URL String
3
  • so true or false will in a json object will convert to a checkbox field as a bool
    – Zdev
    Commented Jan 27, 2023 at 20:05
  • @Zdev That is correct.
    – sfdcfox
    Commented Jan 27, 2023 at 20:06
  • 2
    Worth noting the ISO formatting of date/time values, being in UTC. Weirdly the JSON and REST APIs handle some of this differently, IIRC.
    – Phil W
    Commented Jan 27, 2023 at 20:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .