2

I tried to read multiple JSON files from the browser. The same thing uses with XML in the below code.

sub getcontent()
  content = createObject("roSGNode", "ContentNode")
  contentxml = createObject("roXMLElement")
  if m.top.contenturi.left(4) = "http"
      readInternet = createObject("roUrlTransfer")
      readInternet.setUrl(m.top.contenturi)
      contentxml.parse(readInternet.GetToString())
 else  
   '  contentxml.parse(ReadAsciiFile(m.top.contenturi))
       print "Read Asciifile call...."  
  end if      
  if contentxml.getName()="Content"
    for each item in contentxml.GetNamedElements("item")
      itemcontent = content.createChild("ContentNode")
      itemcontent.setFields(item.getAttributes())
    end for    
 end if      
  m.top.content = content
end sub

This code is working for only XML. Because, i use roXMLElement here. same thing I required to read multiple json from browser uses below code.

searchRequest = CreateObject("roUrlTransfer")
searchRequest.SetURL("http://api.example.com/services/rest/getPhotos")
response = ParseJson(searchRequest.GetToString())

It gives an error in response. Here I use same thing in pass Local URL It's Working fine. only issue with fetching a JSON data from browser

jsonAsString = ReadAsciiFile("pkg:/json/cp.json")
m.json = ParseJSON(jsonAsString)

Anyone know this issue.Thank you.

Joe T
  • 2,300
  • 1
  • 19
  • 31

0 Answers0