# Convert Number to String Kibana JSON Input

**URL:** <https://discuss.elastic.co/t/convert-number-to-string-kibana-json-input/221297>\
**Category:** Kibana\
**Created:** [February 27, 2020, 5:48pm UTC](https://discuss.elastic.co/t/convert-number-to-string-kibana-json-input/221297 "2020-02-27T17:48:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yasir](https://avatars.discourse-cdn.com/v4/letter/y/9f8e36/32.png) [@Yasir](https://discuss.elastic.co/u/Yasir)\
**Post date:** [February 27, 2020, 5:48pm UTC](https://discuss.elastic.co/t/convert-number-to-string-kibana-json-input/221297/1 "2020-02-27T17:48:43Z")

</div>

Hello,

I am trying to use translate in the JSON INPUT to convert ItemValue 0 to Test/String Healthy

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/b/c/bc23bf34a3d5d24f982f947057b6272385b4ee27.png)

I have been trying to use painless in the JSON Input but for some reason it doesnt work.  
Not too familiar with Painless so want some help here on how I can show Healthy for 0 value in the visualizer.

I am hoping I dont have to create a scripted field and do it on the visulalizer.

{  
"script": {  
"inline": if (doc['ItemValue'].value == 0) { return "Healthy"; } return "",  
"lang": "painless"  
}  
}

Is there something I am missing do I need to use .getAsText in the script.

Thanks again for the help in advance

---

<div class="post-metadata">

**Author:** ![markov00](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/markov00/32/33316_2.png) [@markov00](https://discuss.elastic.co/u/markov00)\
**Post date:** [March 23, 2020, 4:02pm UTC](https://discuss.elastic.co/t/convert-number-to-string-kibana-json-input/221297/2 "2020-03-23T16:02:24Z")

</div>

Using an inline `script` you can't cast a value from a number to a string unfortunately. You should use the scripted field for that

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [April 20, 2020, 4:16pm UTC](https://discuss.elastic.co/t/convert-number-to-string-kibana-json-input/221297/3 "2020-04-20T16:16:28Z")

</div>

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