json2typescript
json2typescript copied to clipboard
Class identifiers is unique but still getting error.
@JsonObject('City') // Make sure "City" is a unique identifier for this class export class City {}
Get an error Error: Fatal error in JsonConvert. You must use unique class identifiers in the @JsonObject() decorator. Class identifier: City
"next": "12.2.5",
"react": "18.2.0",
"react-dom": "18.2.0",
"typescript": "4.7.4"
Can you provide a minimal example in a Stackblitz?
I don't think it is possible to get this error with a class definition like above, unless you have a conflict of multiple class names.
Hello, here is example, can be made some changes after saving getting error. https://stackblitz.com/edit/nextjs-9n54xo?file=pages/index.tsx
I don't know what's going on under the hood with nextjs, but the problem seems that your file hello.ts is loaded twice in this application. I was able to verify this fact by adding a console.log into this file. Thus, the class City is read twice and json2typescript throws the error about not having a unique class City.
If you manage to work around this duplicate loading, you will fix the error.
Ok, thanks, I should try to play with reactStrictMode enable and disable in next js config.