I took the liberty to modify OP's input slightly, because as it stands , it's not properly structured json data (due to the {...} part) and implemented a small python script that works with multiple dictionaries, assuming that we're dealing with a dictionary per line. Additionally, as has been discussed in the comments to the question, OP also wanted to remove http:// part.
The script below implements everything discussed above.
#!/usr/bin/env python
import json,sys
with open(sys.argv[1]) as f:
for line in f:
data=json.loads(line)
if data["url"][-1] == '/':
data["url"]=data["url"][:-1].replace('http://','')
if data["originalUrl"][-1] == '/':
data["originalUrl"]=data["originalUrl"][:-1].replace('http://','')
json.dump(data,sys.stdout)
print("")
Test run:
$ cat input.txt
{"url":"http://example.com/vary/file/","originalUrl":"http://example.com/vary/file/","applications":[{"somedata": "blah"}]}
{"url":"http://another-example.com/vary/file/","originalUrl":"http://example.com/vary/file/","applications":[{"somedata": "blah"}]}
$ ./remove_slash.py input.txt
{"url": "example.com/vary/file", "applications": [{"somedata": "blah"}], "originalUrl": "example.com/vary/file"}
{"url": "another-example.com/vary/file", "applications": [{"somedata": "blah"}], "originalUrl": "example.com/vary/file"}
sednothing else. – Jaffer Wilson Feb 07 '17 at 12:11http://from the input. – muru Feb 08 '17 at 04:44http://should be easy, just anothersed 's,http://,,g'– muru Feb 08 '17 at 05:30jsonAPIs (and maybe learn those in the process ). I understand it's fun and simple sometimes to usesedor other tools, butjsonAPIs were created specifically for that purpose. Of course, structuringjsondata properly. Not trying to teach you what to do, but seriously - you can save yourself a lot of time if you start using proper tools for proper job. – Sergiy Kolodyazhnyy Feb 08 '17 at 05:32http://part removed. Because without that, it makes Zanna's and my answer effectively only half-correct. What abouthttps://? do you want those removed as well ? – Sergiy Kolodyazhnyy Feb 08 '17 at 05:34sedcommand from command line. – Jaffer Wilson Feb 08 '17 at 05:41