---
title: "How to add a URL String in a JSON object"  
description: "How to add a URL String in a JSON object"  
author: "Anonymous User"  
published: 2015-12-16  
updated: 2015-12-16  
canonical: https://www.mindstick.com/forum/33743/how-to-add-a-url-string-in-a-json-object  
category: "java"  
tags: ["java", "json"]  
reading_time: 1 minute  

---

# How to add a URL String in a JSON object

I need to add a [URL](https://www.mindstick.com/forum/436/url-redirection) typically in the [format](https://www.mindstick.com/forum/162083/how-to-convert-ost-files-into-pst-format) [http](https://www.mindstick.com/blog/217/http-endpoints-in-sql-server-2005-2008):\somewebsite.com\somepage.asp. When I create a [string](https://www.mindstick.com/articles/1527/string-split-in-c-sharp) with the above URL and add it to [JSON object](https://www.mindstick.com/forum/699/how-to-parse-into-json-object-using-json-parse-in-node-js) json\
using\

```
json.put("url",urlstring);
```

it's appending an [extra](https://www.mindstick.com/blog/63570/5-ways-to-make-money-with-the-extra-space-in-your-home) "\" and when I [check](https://yourviews.mindstick.com/story/2248/never-forget-to-check-these-specifications-before-buying-a-mobile-phone) the [output](https://www.mindstick.com/interview/34427/explain-the-output-in-angular) it's like http:\\somewebsite.com\somepage.asp\
When I give the URL as http://somewebsite.com/somepage.asp the json output is http:\/\/somewebsite.com\/somepage.asp\
Can you help me to [retrieve](https://www.mindstick.com/forum/34400/how-to-retrieve-form-values-in-controller-action) the URL as it is, please?

## Replies

### Reply by Anonymous User

Your [JSON](https://www.mindstick.com/forum/34446/convert-json-string-to-object) library automatically escapes characters like slashes. On the receiving end, you'll have to remove those backslashes by using a function like replace().\
Here's an example:

```
string receivedUrlString = "http:\/\/somewebsite.com\/somepage.asp";<br />string cleanedUrlString  = receivedUrlString.replace('\', '');
```

cleanedUrlString should be "http://somewebsite.com/somepage.asp".


---

Original Source: https://www.mindstick.com/forum/33743/how-to-add-a-url-string-in-a-json-object

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
