ruby - json files saved with trailing "?" -


i'm saving bunch of data hash , saving json file. code saving:

    def write_to_file(id, data)        dir.chdir(file.dirname(__file__)+"/specs")        filename = "./"+id+".json"        file.open("#{filename}", 'w') |f2|             f2.write(data.to_json)        end      end     

i want save id.json, file getting saved "?" @ end. example, 199015806906670?.json original value of "id" 199015806806670.
if search 19901580606670 unable use tab autocomplete. know why happening?

edit: sample file containing ids:

104184946332304
131321736945390
693134284084652
146974018804301
288608807960773

code these:

    url = file.open("newapps/curlist.txt","r")     url.each_line |line|       func1(line) #func1 calls write_to_file, no changes line in func1     end  

as has been mentioned in comments have newline last character of id field. character (being invalid) being replaced question mark.

use remove newline...

filename = "./"+id.chomp+".json" 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -