# Painless Script Convert to JSON not HasMap string

**URL:** <https://discuss.elastic.co/t/painless-script-convert-to-json-not-hasmap-string/255162>\
**Category:** Elasticsearch\
**Created:** [November 12, 2020, 8:01am UTC](https://discuss.elastic.co/t/painless-script-convert-to-json-not-hasmap-string/255162 "2020-11-12T08:01:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajat\_j](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rajat_j/32/78881_2.png) [@rajat\_j](https://discuss.elastic.co/u/rajat_j)\
**Post date:** [November 12, 2020, 8:01am UTC](https://discuss.elastic.co/t/painless-script-convert-to-json-not-hasmap-string/255162/1 "2020-11-12T08:01:24Z")

</div>

I am trying to fetch an array using aggregation. The array is a nested array that contains a list of its own type.  
example :

```auto
        public class Attribute
                {
                    public long Id { get; set; }
                    public string Name { get; set; }
                    public string ImageUrl { get; set; }
                    public List<Attribute> Attributes { get; set; }
                }

```

Now when I running aggregation i am fetching this using **params.\_source.attributes**.  
Output :

```auto
"[{id=1, name=testName, imageUrl=http://sasdasd.com, attributes:[{}] }]"

```

This is a string of HashMap from what I understood. Now my problem is how can I convert this into JSON as I am not able to directly parse HashMap string in c#.

Please assist if there are any parsers to convert it to JSON

---

<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:** [December 10, 2020, 8:01am UTC](https://discuss.elastic.co/t/painless-script-convert-to-json-not-hasmap-string/255162/2 "2020-12-10T08:01:33Z")

</div>

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