[BUG] Probleme with OnDeserialize when multiple array
See original GitHub issueInformation
- Version: 6.59.2
- Packages:
"@tsed/ajv": "6.59.2",
"@tsed/common": "6.59.2",
"@tsed/core": "6.59.2",
"@tsed/di": "6.59.2",
"@tsed/exceptions": "6.59.2",
"@tsed/json-mapper": "6.59.2",
"@tsed/platform-express": "6.59.2",
"@tsed/schema": "6.59.2",
"@tsed/swagger": "6.59.2",
"@tsed/typeorm": "6.43.0",
The object I want to deserialize contain 2 attributes which array array
of typed object
. But in the OnDeserialize
I get the 2 array mixed.
Example
// in foo.ts
import { OnDeserialize } from '@tsed/json-mapper';
export class Foo {
@CollectionOf(String)
@OnDeserialize(features => {
console.log('features:', features);
return features;
})
features: string[];
@CollectionOf(String)
@OnDeserialize(filters => {
console.log('filters:', filters);
return filters;
})
filters: string[];
}
// In bar.controller.ts
@Controller('/bar')
@MergeParams()
export class BarController {
@Post('')
async createFoo(
@Required() @BodyParams() foo: Foo
): Foo {
return foo;
}
When I do POST - http://localhost:3000/foo with this body :
{
"features": ["feature1", "feature2"],
"filters": ["filter1", "filter2"]
}
Here is my console output:
features: [ 'feature1', 'feature2', 'filter1', 'filter2' ]
filters: [ 'feature1', 'feature2', 'filter1', 'filter2' ]
features: [ 'feature1', 'feature2', 'filter1', 'filter2' ]
filters: [ 'feature1', 'feature2', 'filter1', 'filter2' ]
Acceptance criteria
- OnDeserialize should get only the data associated with the named property
- OnDeserialize should be call only one time by property
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:5
Top Results From Across the Web
WCF Serialization Error on HPC - multidimensional array
Trying to serialize some other kind of non serializable object (such as an Exception). To prevent the item from being serialized apply [ ......
Read more >OnDeserialized attribute from NS2 causes runtime error in full ...
Several CSLA base classes use the OnDeserialized attribute to be notified when the BinaryFormatter or NDCS has completed deserializing the ...
Read more >Bug - Error displaying nested arrays in the inspector
After the transition to 2020.3.6, there was a problem with displaying nested arrays if there are more than two of them in the...
Read more >c# - Deserializing JSON when sometimes array and ...
Without using the FacebookMediaJsonConverter, I get an error: Cannot deserialize JSON object into type 'System.Collections.Generic.List`1[FacebookMedia]'. which ...
Read more >was outside the bounds of the array." error with CSLA 3.5 Beta 1
I try with an override of OnDeserialized() now, but it doesn't solve the problem. Maybe I have a some bug in my classes...
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
Hello @Romakita
Thanks for your answer, I’ll check this, maybe something specific we’ve added to our project create this bug.
I’ll let you know when I have more information.
Bye Takeshi
Hello @TakeshiDaveau I’ll try to fix this issue tomorrow 😉
see you Romain