JSON.stringify() in generated service fails to stringify properties of object
See original GitHub issueAbp Version: 4.8.0 using .NET Core
// CreateWadConfigDto.cs
public class CreateWadConfigDto
{
[Required]
[StringLength(WadConfig.MaxNameLength)]
public string Name { get; set; }
}
// Generated typescript class
export class CreateWadConfigDto implements ICreateWadConfigDto {
name: string;
constructor(data?: ICreateWadConfigDto) {
if (data) {
for (var property in data) {
if (data.hasOwnProperty(property))
(<any>this)[property] = (<any>data)[property];
}
}
}
init(data?: any) {
if (data) {
this.name = data["name"];
}
}
static fromJS(data: any): CreateWadConfigDto {
data = typeof data === 'object' ? data : {};
let result = new CreateWadConfigDto();
result.init(data);
return result;
}
toJSON(data?: any) {
data = typeof data === 'object' ? data : {};
data["name"] = this.name;
return data;
}
clone(): CreateWadConfigDto {
const json = this.toJSON();
let result = new CreateWadConfigDto();
result.init(json);
return result;
}
}
export interface ICreateWadConfigDto {
name: string;
}
I cannot seem to find any instance of this happening in other ABP/AN0 products nor any nswag-related projects either.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
json.stringify does not process object methods
JSON.stringify() will encode values that JSON supports. Objects with values that can be objects, arrays, strings, numbers and booleans.
Read more >JSON.stringify() - JavaScript - MDN Web Docs
The JSON.stringify() static method converts a JavaScript value to a JSON string, ... if this object is a property value, the property name ......
Read more >Unable to use JSON.stringify() on a JSON
When trying to use JSON.stringify(), I'm getting the below error: ERROR:: Can't find method com.thingworx.types.primitives.structs.Location.toJSON(string).
Read more >Change JSON.stringify behaviour on certain builtin objects
We accidentaly called JSON.stringify on Error instance with certain non-standard properties. These objects contained _response field, ...
Read more >JavaScript JSON stringify() Method
This argument is used to control spacing in the final string generated using JSON.stringify() function. It can be a number or a string...
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 FreeTop 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
Top GitHub Comments
@maliming Nice catch! Looks like on the ngModel in my template I capitalized the property name. That appears to have fixed the ‘unexpected’ empty result.
It’s strange that the name in your ICreateWadConfigDto class starts with a lowercase letter(
name
), while the screenshot starts with a capital letter(Name
).