Skip to content
GitLab
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
  • #401
Closed
Open
Issue created Dec 23, 2016 by Administrator@rootContributor

JSON Strings with quotes ...

Created by: Humancell

I'm slowly getting the hang of the library, and I'm parsing ok, but now I've hit an issue with comparing/checking values of the properties ... specifically Strings.

Using your example, if I have this JSON:

 char json[] =
      "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";

I can then successfully parse it.

Now, I want to check a value ... and this continues to fail:

  Serial.print("sensor: ");
  if (json.containsKey("sensor"))
  {
    json["sensor"].printTo(Serial);  // NOTE: This prints "gps" with the quotes!
    Serial.println();

    if (json["sensor"]) == "gps") {  // NOTE: Always fails!  Unless changed to "\"gps\""
      /*
       *   How can I compare/get the value WITHOUT the quotes?
       *    - I don't want to have to always put escaped quotes in all comparisons?
       */
    }

How can I do a comparison of a string, but drop the quotes? Or reference the JSON string without the quotes?

Assignee
Assign to
Time tracking