Jump to content

JSON reviver?


davej

Recommended Posts

It seems like a transformation to the object that's done after the object is parsed. A function is called for every single element in the object that's being created and the return value of that function is the value that is used for the element in the resulting object. The function has two arguments: One referring to the key and one referring to the value of the element.

 

I'm not sure why you would use this, but perhaps the program creating the JSON string works differently than the one parsing it and changes need to be made.

Link to comment
Share on other sites

I would still rather use JSON. I don't think I've ever hard parsing issues going back and forth between clients and servers, so a feature like that has never been an issue / of use.

Edited by thescientist
Link to comment
Share on other sites

So neither of you guys use or worry about the reviver thing?

 

I admit that it almost certainly has nothing to do with the simple data collections I will be using.

Edited by davej
Link to comment
Share on other sites

It's just a shortcut to running a conversion function like that after the parsing. Someone decided it would be a good idea to be able to run the conversion function at the same time rather than parse the data structure first, then convert the data if you need to convert it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...