# How to serialize/deserialize action requests to/from json?

**URL:** <https://discuss.elastic.co/t/how-to-serialize-deserialize-action-requests-to-from-json/7940>\
**Category:** Elasticsearch\
**Created:** [June 1, 2012, 8:14am UTC](https://discuss.elastic.co/t/how-to-serialize-deserialize-action-requests-to-from-json/7940 "2012-06-01T08:14:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![benny\_sadeh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/benny_sadeh/32/2797_2.png) [@benny\_sadeh](https://discuss.elastic.co/u/benny_sadeh)\
**Post date:** [June 1, 2012, 8:14am UTC](https://discuss.elastic.co/t/how-to-serialize-deserialize-action-requests-to-from-json/7940/1 "2012-06-01T08:14:26Z")

</div>

hi group,

I was hunting through the java api for a way to serialize/deserialize  
any action request to/from json (IndexRequest / DeleteRequest / etc.)  
and could not find any, which I find surprising as the rest api does  
parse json payload.

the context for such need is using a messaging bus (ie AMQP) to  
execute indexing requests.  
what I'm ending doing right now is using a bytearray payload, by using  
the request.writeTo(StreamOutput) on the producer side and  
request.readFrom(StreamInput) on the consumer side (which also  
mandates parsing the StreamInput header first to figure out the  
request type).

I would very very much prefer to use json as the payload, if only for  
debugging/troubleshooting purposes.  
anyone know how to accomplish that or have used another strategy?

thanks in advance,  
Benny

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [June 3, 2012, 9:52am UTC](https://discuss.elastic.co/t/how-to-serialize-deserialize-action-requests-to-from-json/7940/2 "2012-06-03T09:52:09Z")

</div>

There ins't a need for it in elasticsearch (serializing the action requests  
to json), so its not implemented.

On Fri, Jun 1, 2012 at 10:14 AM, benny.sadeh [benny.sadeh@gmail.com](mailto:benny.sadeh@gmail.com) wrote:

> hi group,
> 
> I was hunting through the java api for a way to serialize/deserialize  
> any action request to/from json (IndexRequest / DeleteRequest / etc.)  
> and could not find any, which I find surprising as the rest api does  
> parse json payload.
> 
> the context for such need is using a messaging bus (ie AMQP) to  
> execute indexing requests.  
> what I'm ending doing right now is using a bytearray payload, by using  
> the request.writeTo(StreamOutput) on the producer side and  
> request.readFrom(StreamInput) on the consumer side (which also  
> mandates parsing the StreamInput header first to figure out the  
> request type).
> 
> I would very very much prefer to use json as the payload, if only for  
> debugging/troubleshooting purposes.  
> anyone know how to accomplish that or have used another strategy?
> 
> thanks in advance,  
> Benny

---

<div class="post-metadata">

**Author:** ![Justin\_Beck](https://avatars.discourse-cdn.com/v4/letter/j/848f3c/32.png) [@Justin\_Beck](https://discuss.elastic.co/u/Justin_Beck)\
**Post date:** [January 7, 2015, 9:36pm UTC](https://discuss.elastic.co/t/how-to-serialize-deserialize-action-requests-to-from-json/7940/3 "2015-01-07T21:36:22Z")

</div>

I was looking for the same thing. I need to execute the same ES action  
(index, create index, delete, etc.) in 3 separate environments (all  
isolated and firewalled). We have a queue that spans environments, so it  
would be easy to have a listener pull a request, build the action and  
execute it. I can do this myself using Kryo or something similar, but  
seems like I'm missing a really easy way to do it.

Let me know if I have.

J

On Sunday, June 3, 2012 5:52:09 AM UTC-4, kimchy wrote:

> There ins't a need for it in elasticsearch (serializing the action  
> requests to json), so its not implemented.
> 
> On Fri, Jun 1, 2012 at 10:14 AM, benny.sadeh \<[benny...@gmail.com](mailto:benny...@gmail.com)  
> \<javascript:\>\> wrote:
> 
> > hi group,
> > 
> > I was hunting through the java api for a way to serialize/deserialize  
> > any action request to/from json (IndexRequest / DeleteRequest / etc.)  
> > and could not find any, which I find surprising as the rest api does  
> > parse json payload.
> > 
> > the context for such need is using a messaging bus (ie AMQP) to  
> > execute indexing requests.  
> > what I'm ending doing right now is using a bytearray payload, by using  
> > the request.writeTo(StreamOutput) on the producer side and  
> > request.readFrom(StreamInput) on the consumer side (which also  
> > mandates parsing the StreamInput header first to figure out the  
> > request type).
> > 
> > I would very very much prefer to use json as the payload, if only for  
> > debugging/troubleshooting purposes.  
> > anyone know how to accomplish that or have used another strategy?
> > 
> > thanks in advance,  
> > Benny

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/9d430ff8-6fdd-4755-8a83-f3cb9c1dd6fb%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/9d430ff8-6fdd-4755-8a83-f3cb9c1dd6fb%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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:** [July 6, 2017, 12:40am UTC](https://discuss.elastic.co/t/how-to-serialize-deserialize-action-requests-to-from-json/7940/4 "2017-07-06T00:40:14Z")

</div>


