Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A ArduinoJson
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 24
    • Issues 24
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Benoît Blanchon
  • ArduinoJson
  • Issues
  • #75
Closed
Open
Issue created 10 years ago by Administrator@rootContributor
  • New related issue

  • Report abuse to administrator

  • New related issue

  • Report abuse to administrator

Add method to measure the JSON length

Closed

Add method to measure the JSON length

Created by: max929292

I am using POST requests to send data to a webserver. These requests only work if we add the content length in the request. I do not want to use a char conversion via printTo as then I need to define the size of the char array which I would like to keep dynamic. I am directly pushing the json to my EthernetClient however I do not know if there is a simple way to pull the content length from it.

Would be great if you could give me some pointers.

EthernetClient client;
JsonObject& root = jsonBuffer.createObject();
....

client.println("POST /datapoints HTTP/1.1");
client.println("Host:  xxx.xxx.xxx.xxx:3000");
client.println("User-Agent: Arduino/1.0");
client.println("Accept: application/json");
client.print("Content-Length: ");
client.println(root.length);    //How can i get length of json? root.length() is not available
client.println("Content-Type: application/json");
client.println("Connection: close");
client.println();
root.printTo(client);
  1. Oh no!

    You are trying to upload something other than an image. Please upload a .png, .jpg, .jpeg, .gif, .bmp, .tiff or .ico.

    Incoming!

    Drop your designs to start your upload.
Tasks
0

No tasks are currently assigned. Use tasks to break down this issue into smaller parts.

Linked items
0

Link issues together to show that they're related. Learn more.

Activity


Please register or sign in to reply
Assignee
Benoît Blanchon's avatar
Benoît Blanchon
Assign to
Labels
1
enhancement
1
enhancement
    Assign labels
  • Manage project labels

Milestone
4.4
4.4
Due date
None
None
None
Time tracking
No estimate or time spent
Confidentiality
Not confidential
Not confidential

You are going to turn on confidentiality. Only project members with at least the Reporter role, the author, and assignees can view or be notified about this issue.

Lock issue
Unlocked
2
2 participants
Benoît Blanchon
Administrator
Reference: bblanchon/ArduinoJson#75

Menu

Explore Projects Groups Snippets