You need to sign in to do that
Don't have an account?
ThisIsRSN
How "Type: Object" is used in Salesforce
Hi ,
I am curious to know which method for "type: object" are supported in salesforce.
What its use and how it can be leaveraged in salesforce.
Thanks
_RSN
Object is analogous to Java's java.lang.Object. However, unlike java.lang.Object, it has no static or instance methods or properties. In other words, it can only be used as a dynamic data type that can refer to any other type. Any data type may be implicitly stored as an object (no casting required), but requires a cast to convert the object to any other data type. Most of the valueof static methods support object as a parameter, and the operators ==, !=, ===, and instanceof support objects as operands.
You can do the following things with Object:
Basically, it is used to represent generic types. For example, JSON.deserialize returns an Object-- you then cast that Object into the appropriate type, such as a class, a primitive, or an SObject. Similarly, JSON.serialize accepts an object as a parameter-- the function takes all of the properties of the object and serialize them. There are several functions that take generic objects as their parameters, or return generic objects, in order to support a wide range of parameters.
All Answers
Hi,
In salesforce, we have sObject, not Object. Do you mean you want to know about sObject?
Happy to help you!
Regards,
Digamber Prasad
Hi Digamber,
Thanks for your reply.
I am aware of SObject. But there is a generic object called "Object" in Java. This object can be used in Apex also. But i can't see some of its the methods in Apex say getClass(). When i tried to use it , it throws error.
So, i wanted to know the scope of this type ("Object") in apex.
Thanks
Rajendra
Object is analogous to Java's java.lang.Object. However, unlike java.lang.Object, it has no static or instance methods or properties. In other words, it can only be used as a dynamic data type that can refer to any other type. Any data type may be implicitly stored as an object (no casting required), but requires a cast to convert the object to any other data type. Most of the valueof static methods support object as a parameter, and the operators ==, !=, ===, and instanceof support objects as operands.
You can do the following things with Object:
Basically, it is used to represent generic types. For example, JSON.deserialize returns an Object-- you then cast that Object into the appropriate type, such as a class, a primitive, or an SObject. Similarly, JSON.serialize accepts an object as a parameter-- the function takes all of the properties of the object and serialize them. There are several functions that take generic objects as their parameters, or return generic objects, in order to support a wide range of parameters.
Thanks Fox, This is the answer i was expecting. :)