Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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 ?

share|improve this question
    
so you want to convert a string to a byte array? –  gipinani Jan 11 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. –  Lars Blumberg Jan 11 at 20:22
    
You don't have a JSON array, but a JSON Object. Do you want to POST JSON to a webserver? –  hgoebl Jan 11 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 –  user1002448 Jan 14 at 6:15

1 Answer 1

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

Pass your JSONArray as the object here.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.