Objects get gutted
|Everyday inline use|
Important CJC.js must be included in the source stack before it is actually used. This can be a gotcha as you might be doing things like loading configurations very early on.
|Convert anything to JSON||myStr = CJC.ToJ(Anything)
An alias CJC.toJSON() is available.
|Create an object from JSON||myThing = CJC.FromJ(Jstring)|
Non-JSON gets returned as-is.
An alias CJC.fromJSON() is available.
|Register constructors|| CJC.RegisterConstructors(ArrayOfConstructors)
Typically this will appear at the bottom of the source code unit where classes are defined and reference all classes it defines.
|Prevent stringification|| CJC.Block(Class,ClassName)
Sometimes it's essential or just unnecessary to export a sub-element. A good example of this is a DOM element which is used for placemarking etc while the object is doing its stuff in the browser but doesn't need to be persisted. If you use jQuery then something like this.placeInDom = $('#contentGoesHere'); is valid and useful, but if you try to export/import you'll hit a big snag. this.placeInDom is actually a jQuery object which CJC will happily stringify... ... but fail to import into another session as jQuery is now a new object for a new session. So blocking export is a good thing as it saves a whopping storage bill for something which doesn't need storing anyway.
Example: jQuery is blocked by default but if it wasn't you could use CJC.DoNotStringify(jQuery,'jQuery');
Another reason for blocking export of referenced classes is when you use the following pattern:
An alias CJC.doNotStringify() is available.
|Clone a class instance||Sometimes you need to clone an object and completely disconnect it from any references. Typical cloning methods copy references inside the object. (Often you want this, but sometimes you don't.) CJC.DeepCopy(OriginalClassInstance) is a convenience function to do this. It's really 'To' and 'From' back-to-back with blocks disabled.|
|About the code||CJC.about Version and pointer to this reference page.|
|Registered constructors||CJC.DumpConstructorNames() just for debugging.|
|Global||CJC_DATA is used internally by CJC and shouln't be hacked.|
|Footnote||In my world functions and methods are always initially capitalised. If this offends you then use the alternatives.
|Cstore.js||Easy to use local storage and server file storage with CJC built-in. Has a really clever method to create self-saving objects.|
|Implements the very common paradigm of a list of objects. Works with Cstore straight out of the box.|
|Documentation for classes (Hint:they often inherit methods) and dependencies. Search and produce API references.|