I have a String content="" and if I put an HTTP request like this:

client.println("GET /api/actions?parking_id=39 HTTP/1.1");
client.println("Host: ramp-rampcontrol.rhcloud.com");
client.println("Connection: close");

the output I get is:

 [{"action_id":35,"action_type":"up","parking_id":39,"user_id":17,"ramp":"exit","created_at":"2015-07-10 18:02:40","updated_at":"2015-07-10 18:02:40"},{"action_id":41,"action_type":"up","parking_id":39,"user_id":17,"ramp":"entry","created_at":"2015-08-16 20:50:14","updated_at":"2015-08-16 20:50:14"},{"action_id":42,"action_type":"down","parking_id":39,"user_id":17,"ramp":"entry","created_at":"2015-08-16 20:50:21","updated_at":"2015-08-16 20:50:21"},{"action_id":43,"action_type":"down","parking_id":39,"user_id":17,"ramp":"exit","created_at":"2015-08-16 20:50:22","updated_at":"2015-08-16 20:50:22"}]

The little parser I created is this:

while(client.available()) {
 char c = client.read();   
    if(c == '{'){
      begin1 = true;

  if (begin1) { 
    content += c;

  if (c == '}') {

Is it possible to store only the first action in JSON output, because the actions are updated, and if the number of chars extends 256 than I get errors while working with the String content?

  • if (c == ',') { break; } (i.e. break on the first comma, instead of the first closing bracket)
    – Gerben
    Sep 16, 2015 at 14:09

1 Answer 1


Your question is not clear to me. First of all does your parser get the whole response? And second by first action do you mean "action_id":35"? If both are true then your solution is simple.

First you separate every comma ", " and put in a string array then you further split each index by ":" so the first part is the name "action_id" and the second is the value "35". I hope that helps . You can look up the split function, it's easy.

But if the above is not what you needed then I am afraid you cannot get only the first response, because that has to do with the server itself.

Here is a solution, do try it.

I found an easier solution. Follow the example and replace the content and fields with your response content and you will be done in minutes.

  • Yes, the parser gets the whole response. I need only the first one stored in String content which in this example is : [{"action_id":35,"action_type":"up","parking_id":39,"user_id":17,"ramp":"exit","created_at":"2015-07-10 18:02:40","updated_at":"2015-07-10 18:02:40"}
    – FunKction
    Sep 16, 2015 at 11:28
  • 2
    Darkclaude X, please edit your answer and adjust the unconventional, hard-to-read capitalization. Capitalize the first word of each sentence; capitalize proper nouns and the pronoun I; don't capitalize other words. Also, please spellcheck “Seperate”. Sep 16, 2015 at 15:08
  • thx Jwpat, FunKction check the library above Sep 16, 2015 at 18:34
  • Your question is not clear to me. Getting clarification on questions belongs in the comments, not in an answer. Please adjust your answer and comment accordingly.
    – Jake C
    Sep 18, 2015 at 3:00
  • 1
    Unfortunately i cant comment on his Post i need 50 points Sep 18, 2015 at 21:01

Your Answer

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

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