On Mon, Jan 4, 2021 at 7:06 AM Vinayaka Kamath
<vinayaka.kam...@couchbase.com> wrote:
>
> Hello All,
>
> I am looking for the fastest way to check if a v8::Local<v8::Value> is JSON 
> serialisable or not.
>
> Some negative cases are: undefined, {"foo": undefined}, Object({ })
>
> Thanks!

Simply trying to serialize it is really the only way from a
correctness perspective.

Objects can have .toJSON() methods (IOW, can execute arbitrary code
during serialization) so there is really no way to know what the
serialized object graph looks like until you try it.

By the way, all the negative cases you mention are in fact valid
inputs, they all produce an output when you pass them to
JSON.stringify().

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/v8-users/CAHQurc8L3xcXha88MTwPZsMSRyHaxr9WnOdHPXNjSU5rbSX3fA%40mail.gmail.com.

Reply via email to