title: Exposing Objective-c object to JavaScript environment in JSON format
body: <p>I want to represent any objective-c object in JSON format at RUNTIME, so that a javascript script can use it to access any field/variables/properties through 'dot' notation. </p>
  
  <p>For example, </p>
  
  <p><strong>Objective-c class for the object could be:</strong></p>
  
  <pre><code>@interface myNativeObject 
     PrimtivieType *pVar;
     CustomClassType *cVar;
  @end
  </code></pre>
  
  <p><strong>Where CustomClassType may contain another object as shown below:</strong></p>
  
  <pre><code>@interface CustomDataType
    PrimitiveType *myVar;
  @end
  </code></pre>
  
  <p><strong>I want to Expose myNativeObject to JavaScript in JSON format, as follows:</strong></p>
  
  <pre><code>    var nativeObjInJavaScript = {
                                    pVar:pval,
                                    cVar:{
                                           myVar:myVarValue
                                    }
                                  }
  </code></pre>
  
  <p><strong>So, now following JavaScript expression shoule work correctly:</strong></p>
  
  <pre><code>var LValue = nativeObjInJavaScript.cVar.myVar;
  </code></pre>
  
  <p>I am thinking of </p>
  
  <p>1.) writing a recursive function which will use Objective-C runtime library to get information about the object and generate the JSON equivalent. Am I on the right track?</p>
  
  <p>2.) Key-Value encoding feature of Objective-c could be of any help in this case?</p>
  
  <p>Regards,</p>