2

I have the following jsonarray:

{
"_id" :"value", "data": "value", "array" : [{ "x" : "value", "y" : "value" }, { "x" : "value", "y" : "value" }] }

How to convert this to byte[] array ?

4
  • so you want to convert a string to a byte array? Commented Jan 11, 2014 at 20:17
  • Your questions is not very clear. Can you say why do you want to convert it to a byte array? This would help others answering. Commented Jan 11, 2014 at 20:22
  • You don't have a JSON array, but a JSON Object. Do you want to POST JSON to a webserver? Commented Jan 11, 2014 at 22:35
  • I need to convert a json array to bytearray. I am going to use OKHTTP. It takes byte array as parameter. so i need the json to be converted to byte arrya Commented Jan 14, 2014 at 6:15

1 Answer 1

4
public byte[] objectToBytArray( Object ob ){
 return ((ob.toString()).getBytes());
}

Pass your JSONArray as the object here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.