serializer example on @jsonObejct
See original GitHub issueI used serializer on @jsonObejct, but it has error below,
Argument of type '{ serializer: (myClass: MyClass) => any; }' is not assignable to parameter of type 'ParameterlessConstructor<{}>'.
Object literal may only specify known properties, and 'serializer' does not exist in type 'ParameterlessConstructor<{}>'.ts(2345)
My codes like
@jsonObject({
serializer: MyClass.toJson // error spot
})
export class MyClass extends BaseEntity {
static toJson(myClass: MyClass): any {
//serialization from MyClass to json.
}
:
}
Anyone give me some example using serializer on @jsonObejct? Or any idea?
Issue Analytics
- State:
- Created 4 years ago
- Comments:8
Top Results From Across the Web
How to serialize JSON object in java - Stack Overflow
Have a look at Gson library. It does nice JSON to object mapping and serialization. ... Use the .toString() method of JSONObject to...
Read more >How to serialize a JSON object with JsonWriter using Object ...
In the below example, we can serialize a JSON object using the JsonWriter interface. Example. import java.io.StringWriter; import ...
Read more >JSON serialization and deserialization in Java with JSON-Java
Java JSON tutorial shows how to do JSON serialization and deserialization ... In the following example, we create a JSONObject from a Map....
Read more >JSON Serialize | Guide to Syntax and Examples of ... - eduCBA
Example #3. Javascript JSON object serialization using a numerical value. The argument is used to control white spaces and control indentation.
Read more >Serializing and Deserializing JSON - Json.NET
The quickest method of converting between JSON text and a .NET object is using the T:Newtonsoft.Json.JsonSerializer. The JsonSerializer converts .
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You could have something like this. I’ve also added a test for that. So, you can take a look in the repository.
I found it out. Instead of “null”, you can use “undefined”.
The result of serializing this code is blank { }.