-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
toString returns [Object object] #9
Comments
Did you figure this out? If not, would you mind posting some of your code (where it evaluates to |
@NicolasDeveloper Is this repo being maintained at all? There's not much on here but I can help out with issues and PRs. |
So sorry, I didn't had time to fix it yet, but this week I'll do and update the npm |
@AstaraelWeeper I don't see how this is an error. Only if you call |
I have the exact same problem. I'm using Angular and I am passing the Guid as a parameter of the click function for the button, like this:
Might be an Angular thing tho. |
I think this seems to be a problem caused by deserialising JSON. Here's a small sample that produces this issue: type MyType = {
MyGuid: Guid;
}
const instance: MyType = {
MyGuid: Guid.create()
}
// All good...
console.log(instance.MyGuid);
console.log(instance.MyGuid.toString());
const serialized = JSON.stringify(instance);
const deserialised: MyType = JSON.parse(serialized);
// Seems OK - outputs an object where `value` is a guid string
console.log(deserialised.MyGuid);
// Bad - outputs [object Object]
console.log(deserialised.MyGuid.toString()); To be honest, this issue renders the |
What I resorted to do is refactor my code and store all GUIDs as plain strings. But I still use this library when I need to generate a GUID (immediately converting it to a string: |
Hi, I'm using this in Ionic 4 and wasn't able to get the value of the GUID using .toString(), as it returns "[Object object]" as though it's using the normal toString instead of your class one, although hovering on it does indicate it uses the right one. using .toJSON also didn't work, as it said "is not a function".
I was only able to get the value using
var stringId = JSON.stringify(id);
var json =JSON.parse(stringId);
The text was updated successfully, but these errors were encountered: