RUBY script reads a jason


#1

I need the parameters from the Jason file which is supplied from the
legacy system to use those parameter values in the program module am
building. can you suggest me any code to read out the jason file.
Let me know if you want me to ask them to modify the jason inorder to be
used by me.

The jason file example is attached in the system.


#2

Pretty awkward way to store JSON as image.

Have you tried to load the file yet?

Try in IRB:

require “json”

data = JSON.parse(path)

http://ruby-doc.org/stdlib-2.4.0/libdoc/json/rdoc/JSON.html#method-i-parse


#3

Robert H. wrote in post #1185569:

Pretty awkward way to store JSON as image.

Have you tried to load the file yet?

Try in IRB:

require “json”

data = JSON.parse(path)

http://ruby-doc.org/stdlib-2.4.0/libdoc/json/rdoc/JSON.html#method-i-parse

Thanks Robert it json has worked for me, the json is in the form of a
notepad i had to take a snap to upload it onto the forum


#4

Could you please help me out with the code to hit the URL to get a
response for the JASON file. I use ruby 1.8.7.

require “net/https”
require “uri”

uri = URI.parse(“https://secure.com/”)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(uri.request_uri)

response = http.request(request)
response.body
response.status
response[“header-here”] # All headers are lowercase

I get this error for running the above code

in `initialize’: getaddrinfo: The storage control blocks were destroyed.
(SocketError)

Thanks,
Sai