title: VBScript Object Compose
body: <p>So i'm using a vbscript code through my Com Objects in order to decode a json file
  at first my VBs code was:</p>
  
  <pre><code>Function filejson(json) 
    On Error Resume Next
    Dim objStream, strData 
    Set objStream = CreateObject("ADODB.Stream") 
    objStream.CharSet = "utf-8" 
    objStream.Open 
    objStream.LoadFromFile(json) 
    strData = objStream.ReadText()
    filejson=strData
  End Function 
  
  Function str2json(json,value) 
    On Error Resume Next
    Set scriptControl = CreateObject("MSScriptControl.ScriptControl") 
    scriptControl.Language = "JScript" 
    Set searchResultObject = scriptControl.Eval("(" + json + ")")
    str2json=Eval("searchResultObject" &amp; value )
  End Function
  
  Function result(json,value)
     On Error Resume Next
     result=str2json(filejson(json),value)
  End Function
  </code></pre>
  
  <p>So i was just taking every value i wanted just with </p>
  
  <pre><code>result("movie.json",".adult") for example:
  </code></pre>
  
  <p>With Json:</p>
  
  <pre><code>{"adult":false,"backdrop_path":"/hbn46fQaRmlpBuUrEiFqv0GDL6Y.jpg"}
  </code></pre>
  
  <p>And i was taking just fine the "false"</p>
  
  <p>But then , my jsons got more tricky... </p>
  
  <pre><code>{"adult":false,"backdrop_path":"/hbn46fQaRmlpBuUrEiFqv0GDL6Y.jpg","belongs_to_collection":{"id":86311,"name":"The Avengers Collection","poster_path":"/qJawKUQcIBha507UahUlX0keOT7.jpg","backdrop_path":"/zuW6fOiusv4X9nnW3paHGfXcSll.jpg"}}
  </code></pre>
  
  <p>But still i was able to get data from there with my second argument: ".belongs_to_collection.id" Until THIS:</p>
  
  <pre><code>{
      "adult": false,
      "backdrop_path": "/hbn46fQaRmlpBuUrEiFqv0GDL6Y.jpg",
      "belongs_to_collection": {
          "id": 86311,
          "name": "The Avengers Collection",
          "poster_path": "/qJawKUQcIBha507UahUlX0keOT7.jpg",
          "backdrop_path": "/zuW6fOiusv4X9nnW3paHGfXcSll.jpg"
      },
      "alternative_titles": {
          "titles": [
              {
                  "iso_3166_1": "IT",
                  "title": "I vendicatori"
              },
              {
                  "iso_3166_1": "BR",
                  "title": "Os Vingadores"
              },
              {
                  "iso_3166_1": "GB",
                  "title": "Avengers Assemble"
              },
              {
                  "iso_3166_1": "US",
                  "title": "Marvel's The Avengers"
              },
              {
                  "iso_3166_1": "SE",
                  "title": "Avengers 3D"
              },
              {    
                 "iso_3166_1": "ES",
                  "title": "Marvel Los Vengadores"
              },
              {
                  "iso_3166_1": "PL",
                  "title": "Avengers 3D"
              },
              {
                  "iso_3166_1": "IL",
                  "title": "הנוקמים"
              },
              {
                  "iso_3166_1": "US",
                  "title": "The Avengers 3D"
              },
              {
                  "iso_3166_1": "CZ",
                  "title": "Avengers"
              },
              {
                  "iso_3166_1": "TW",
                  "title": "復仇者聯盟"
              },
              {
                  "iso_3166_1": "DE",
                  "title": "Marvel's The Avengers - Die Rächer"
              },
              {
                  "iso_3166_1": "DE",
                  "title": "The Avengers - Die Rächer"
              },
              {
                  "iso_3166_1": "VE",
                  "title": "Los Vengadores"
              }
          ]
      }
  }
  </code></pre>
  
  <p>And i tried to get one of the alternative titles, i tried with my default method...<br>
  result("movie.json",".alternative_titles.titles.0.title") but null was what i got...</p>
  
  <p>So i used it for<br>
  result("movie.json",".alternative_titles.titles") to check the result
  and the result was:</p>
  
  <pre><code>[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
  </code></pre>
  
  <p>After some time trying to figure out what to do since i couldn't access the sub object with a simple number (.1 , .0 ...) i tried to create a function to do things a bit more easier, though failed:</p>
  
  <pre><code>Function filejson(json) 
    On Error Resume Next
    Dim objStream, strData 
    Set objStream = CreateObject("ADODB.Stream") 
    objStream.CharSet = "utf-8" 
    objStream.Open 
    objStream.LoadFromFile(json) 
    strData = objStream.ReadText()
    filejson=strData
  End Function 
  
  Function str2json(json,value) 
    On Error Resume Next
    Set scriptControl = CreateObject("MSScriptControl.ScriptControl") 
    scriptControl.Language = "JScript" 
    Set searchResultObject = scriptControl.Eval("(" + json + ")")
    parameters=Split(value,".")
    fullparm="obj"
    obj=Eval("searchResultObject" &amp; fullparm )
    For Each parm in parameters
        MsgBox("Parameter: "&amp;parm&amp;" | Old Object: "&amp; obj)
        If Eval("obj."&amp;parm) = "[object Object]" Then
            If IsNumeric(parm) Then
                i=0
                For Each new_obj in obj
                    If Trim(i) = Trim(parm) then
                        MsgBox("New Object: " &amp; "obj | Value: " &amp; new_obj)
                        obj=new_obj
                        fullparm="obj."
                    End If
                    i=i+1
                 Next
            Else
                obj=Eval("obj." &amp; parm)
                fullparm=fullparm&amp;"."&amp;parm
                MsgBox("New Object: " &amp; "obj." &amp; parm &amp; " | Value: " &amp; obj)
            End If
        Else
            str2json=obj
            Exit Function
        End If
    Next
    MsgBox(fullparm)
    str2json="false"
  End Function
  Function result(json,value)
      On Error Resume Next
      result=str2json(filejson(json),value)
  End Function
  </code></pre>
  
  <p>Any ideas how to manage to Get the value i want by just having the same input?   </p>
  
  <p>"alternative_titles.titles.0.title" (get 1 sub object.title).<br>
  Also it could have more than one sub dimension...jsons....    </p>
  
  <p>And i HAVE to use VBScript and NOT JScript. It used within combojects.<br>
  with JScript its not able to open a file with UTF8. IN VBScript it is with ADODB.Stream</p>