# Text to JSON string

**URL:** <https://forum.uipath.com/t/text-to-json-string/144824>\
**Category:** フォーラム\
**Tags:** studio\
**Created:** [August 25, 2019, 6:44am UTC](https://forum.uipath.com/t/text-to-json-string/144824 "2019-08-25T06:44:56Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kitty](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kitty/32/71692_2.png) [@Kitty](https://forum.uipath.com/u/Kitty)\
**Post date:** [August 25, 2019, 6:44am UTC](https://forum.uipath.com/t/text-to-json-string/144824/1 "2019-08-25T06:44:56Z")

</div>

Text文字をJSONフォマード変更したいですが、如何すれば教えていただけないでしょうか？

例えば、  
Text :  
My name is Kitty.  
I like “RPA”.

JSON:  
My name is Kitty./nI like /“RPA/”.

---

<div class="post-metadata">

**Author:** ![HareeshMR](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hareeshmr/32/181825_2.png) [@HareeshMR](https://forum.uipath.com/u/HareeshMR)\
**Post date:** [August 25, 2019, 6:58am UTC](https://forum.uipath.com/t/text-to-json-string/144824/2 "2019-08-25T06:58:49Z")

</div>

> [@Kitty](#):
>
> My name is Kitty./nI like /“RPA/”.

This is not at all a JSON format @Kitty

Can you make the question a bit clear

---

<div class="post-metadata">

**Author:** ![Kitty](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kitty/32/71692_2.png) [@Kitty](https://forum.uipath.com/u/Kitty)\
**Post date:** [August 25, 2019, 7:02am UTC](https://forum.uipath.com/t/text-to-json-string/144824/3 "2019-08-25T07:02:24Z")

</div>

Thank you for your question. I am sorry for my blurry question.  
May I know do you call the format below?  
I want to change my text message to the following format.  
Please teach me.

“text”: “\n◆関東遅延情報 8月7日 08時17分\nhttps:\/\/transit.yahoo.co.jp\/traininfo\/area\/4\/\n━─━─━─━─━─━─━─━\n内房線\n\n袖ケ浦～巌根駅間で踏切内点検を…\n━─━─━─━─━─━─━─━\n京葉線\n\n武蔵野線内で発生した線路内立入…\n━─━─━─━─━─━─━─━\n武蔵野線\n\n南浦和駅で発生した線路内立入の…\n━─━─━─━─━─━─━─━\n東武アーバンパークライン\n\n05:45頃、七光台駅構内で発…\n━─━─━─━─━─━─━─━\nシーサイドライン\n\n6月1日、新杉田駅で発生した衝…\n━─━─━─━─━─━─━─━”,  
“ts”: “1565133474.000100”,

---

<div class="post-metadata">

**Author:** ![AshwinS2](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ashwins2/32/176686_2.png) [@AshwinS2](https://forum.uipath.com/u/AshwinS2)\
**Post date:** [August 25, 2019, 7:10am UTC](https://forum.uipath.com/t/text-to-json-string/144824/4 "2019-08-25T07:10:23Z")

</div>

Hi @Kitty

Try to use deserialize json activity

Based on that you can convert it

Thanks  
Ashwin.S

---

<div class="post-metadata">

**Author:** ![HareeshMR](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hareeshmr/32/181825_2.png) [@HareeshMR](https://forum.uipath.com/u/HareeshMR)\
**Post date:** [August 25, 2019, 7:11am UTC](https://forum.uipath.com/t/text-to-json-string/144824/5 "2019-08-25T07:11:59Z")

</div>

Can you post the text you have @Kitty/

---

<div class="post-metadata">

**Author:** ![Kitty](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kitty/32/71692_2.png) [@Kitty](https://forum.uipath.com/u/Kitty)\
**Post date:** [August 25, 2019, 7:17am UTC](https://forum.uipath.com/t/text-to-json-string/144824/6 "2019-08-25T07:17:22Z")

</div>

> [@AshwinS2](#):
>
> deserialize json

Thank you for your answer. Thats converting JSON string to JSON object right?  
I will remember this.

I’m sorry I think my questions were inaccurate.  
I want to convert my text (.txt) to JSON string (str) format.

---

<div class="post-metadata">

**Author:** ![Kitty](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kitty/32/71692_2.png) [@Kitty](https://forum.uipath.com/u/Kitty)\
**Post date:** [August 25, 2019, 7:34am UTC](https://forum.uipath.com/t/text-to-json-string/144824/7 "2019-08-25T07:34:04Z")

</div>

Hi thank you Mr Hareesh.  
I want to convert my text to JSON string.  
I have alot of text which I want to convert to JSON object but before it I need the text to be in string format. I do not know the proper term which we call them.

One example of my text is  
My name is Kitty.  
I am not a “cat”!

I want it to convert to  
My name is Kitty.\r\nI am not a "cat"!

---

<div class="post-metadata">

**Author:** ![HareeshMR](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hareeshmr/32/181825_2.png) [@HareeshMR](https://forum.uipath.com/u/HareeshMR)\
**Post date:** [August 25, 2019, 7:59am UTC](https://forum.uipath.com/t/text-to-json-string/144824/8 "2019-08-25T07:59:13Z")

</div>

> [@Kitty](#):
>
> My name is Kitty.\r\nI am not a “cat”!

Again this is not a JSON format @Kitty

The JSON of this should be like this

{  
{  
" My name is Kitty"  
},  
{  
“I am not a “cat”!”  
}  
}

Or you can write them in a single object also

Or even arrays, But the one you are posting is not a JSON string 🙂

Please let me know the correct type of JSON you need and

**I have never tried of converting text to JSON , but it is very interesting to try and learn that**

---

<div class="post-metadata">

**Author:** ![Kitty](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kitty/32/71692_2.png) [@Kitty](https://forum.uipath.com/u/Kitty)\
**Post date:** [August 25, 2019, 8:12am UTC](https://forum.uipath.com/t/text-to-json-string/144824/9 "2019-08-25T08:12:51Z")

</div>

Thank you so much for your kind explanation.

I am not an engineer so I do not know the term you call it.  
What I want is as follows

* * *

**Input**  
My name is Kitty.  
I am not a “cat”!

**Output**  
“My name is Kitty.\nI am not a "cat"!”

* * *

.toStr doesnt work as the output does not include \n.  
Do you know where can I find the code to do the conversion?

Please help me.

---

<div class="post-metadata">

**Author:** ![HareeshMR](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hareeshmr/32/181825_2.png) [@HareeshMR](https://forum.uipath.com/u/HareeshMR)\
**Post date:** [August 25, 2019, 8:28am UTC](https://forum.uipath.com/t/text-to-json-string/144824/10 "2019-08-25T08:28:16Z")

</div>

So, you want the every line of the text you have in a single line with \n appended after every line @Kitty

Am I right?

---

<div class="post-metadata">

**Author:** ![Kitty](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kitty/32/71692_2.png) [@Kitty](https://forum.uipath.com/u/Kitty)\
**Post date:** [August 25, 2019, 8:33am UTC](https://forum.uipath.com/t/text-to-json-string/144824/11 "2019-08-25T08:33:55Z")

</div>

Yeah thats right.

I am not sure of other rules.  
For example if the message contains ", I need to put \ in front of the "  
Or, if the message contains , I need to add \ in front of the .

---

<div class="post-metadata">

**Author:** ![HareeshMR](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/hareeshmr/32/181825_2.png) [@HareeshMR](https://forum.uipath.com/u/HareeshMR)\
**Post date:** [August 25, 2019, 9:04am UTC](https://forum.uipath.com/t/text-to-json-string/144824/12 "2019-08-25T09:04:45Z")

</div>

[ReadTextFIle.xaml](https://forum.uipath.com/uploads/short-url/jQtiK0X4kLL3WG7Wt7r2Jh8aH85.xaml) (7.0 KB)

This is the workflow which will give you the expected output @Kitty,

I mean read the text and give you the string in a single line with \n appended

get back to me if you have any other doubts

---

<div class="post-metadata">

**Author:** ![Kitty](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/kitty/32/71692_2.png) [@Kitty](https://forum.uipath.com/u/Kitty)\
**Post date:** [August 25, 2019, 9:47am UTC](https://forum.uipath.com/t/text-to-json-string/144824/13 "2019-08-25T09:47:20Z")

</div>

Hi. Thanks so much for the file Mr Hareesh.  
You are a lifesaver

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [August 28, 2019, 9:50am UTC](https://forum.uipath.com/t/text-to-json-string/144824/14 "2019-08-28T09:50:22Z")

</div>

Closed on August 28, 2019, 9:50am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
