user66535: How to convert JSON String for example
{"f0":100,"f1":100,"f2":100}

It is what I get from my esp01 side from I2C communication
Now I want it to get it back to my Arduino side variables int f0 ,int f1 ,int f2 
But example shown in web site uses kind of different serialized JSON
Example shown,
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}";
Can I convert the data I got from I2C communication for using in the method for deserializeJson(jsonobj, stringofdata)
I2C communication side of arduino looks like,
void receiveEvent(size_t howMany) {
  String datain = "";
  while (0 < Wire.available()) {
    char c = Wire.read();
    datain += c;
  }
  Serial.println(datain);
//be careful can't send too much json data I2C crash!
  Serial.println(datain.length());
  DynamicJsonDocument datajson(100);
  if (deserializeJson(datajson, datain)) {
    Serial.print("deserialization ok ");
    digitalWrite(13, HIGH);
    delay(250);
    digitalWrite(13, LOW);
    f0 = datajson["f0"];
    f1 = datajson["f1"];
    f2 = datajson["f2"];

    Serial.println(String(f0) + " " + String(f1) + " " + String(f2));
  }


}

In serial monitor I only see this no deserialization worked
{"f0":0,"f1":0,"f2":0}
22


user66535: The mistake I did was thinking deserializeJson(datajson, datain) gives a Boolean as true for correct deserialization but accually it gives an object of DeserializationError err so need to check if there is no error thus
The new code
// need ! here
  if (!deserializeJson(datajson, datain)) {
    Serial.println("yay it worked");
    Serial.print("deserialization ok ");
    digitalWrite(13, HIGH);
    delay(250);
    digitalWrite(13, LOW);
    f0 = datajson["f0"];
    f1 = datajson["f1"];
    f2 = datajson["f2"];

    Serial.print(f0);
    Serial.print(" ");
    Serial.print(f1);
    Serial.print(" ");
    Serial.println(f2);

//also tested this way and it works too
    Serial.println(String(f0) + " " + String(f1) + " " + String(f2));
  } else {
    // I was coding here thinking its Boolean before
    //error
  }


66535: <p>How to convert JSON String for example</p>
<pre><code>{&quot;f0&quot;:100,&quot;f1&quot;:100,&quot;f2&quot;:100}
</code></pre>
<p>It is what I get from my esp01 side from I2C communication</p>
<p>Now I want it to get it back to my Arduino side variables <code>int f0 ,int f1 ,int f2 </code></p>
<p>But example shown in <a href="https://arduinojson.org" rel="nofollow noreferrer">web site</a> uses kind of different serialized JSON</p>
<p>Example shown,</p>
<p><code>char json[] = &quot;{\&quot;sensor\&quot;:\&quot;gps\&quot;,\&quot;time\&quot;:1351824120,\&quot;data\&quot;:[48.756080,2.302038]}&quot;;</code></p>
<p>Can I convert the data I got from I2C communication for using in the method for <code>deserializeJson(jsonobj, stringofdata)</code></p>
<p>I2C communication side of arduino looks like,</p>
<pre><code>void receiveEvent(size_t howMany) {
  String datain = &quot;&quot;;
  while (0 &lt; Wire.available()) {
    char c = Wire.read();
    datain += c;
  }
  Serial.println(datain);
//be careful can't send too much json data I2C crash!
  Serial.println(datain.length());
  DynamicJsonDocument datajson(100);
  if (deserializeJson(datajson, datain)) {
    Serial.print(&quot;deserialization ok &quot;);
    digitalWrite(13, HIGH);
    delay(250);
    digitalWrite(13, LOW);
    f0 = datajson[&quot;f0&quot;];
    f1 = datajson[&quot;f1&quot;];
    f2 = datajson[&quot;f2&quot;];

    Serial.println(String(f0) + &quot; &quot; + String(f1) + &quot; &quot; + String(f2));
  }


}
</code></pre>
<p>In serial monitor I only see this no deserialization worked</p>
<pre><code>{&quot;f0&quot;:0,&quot;f1&quot;:0,&quot;f2&quot;:0}
22
</code></pre>
 66535: <p>The mistake I did was thinking <code>deserializeJson(datajson, datain)</code> gives a Boolean as <code>true</code> for correct deserialization but accually it gives an object of <code>DeserializationError err</code> so need to check if there is no error thus</p>
<p>The new code</p>
<pre><code>// need ! here
  if (!deserializeJson(datajson, datain)) {
    Serial.println(&quot;yay it worked&quot;);
    Serial.print(&quot;deserialization ok &quot;);
    digitalWrite(13, HIGH);
    delay(250);
    digitalWrite(13, LOW);
    f0 = datajson[&quot;f0&quot;];
    f1 = datajson[&quot;f1&quot;];
    f2 = datajson[&quot;f2&quot;];

    Serial.print(f0);
    Serial.print(&quot; &quot;);
    Serial.print(f1);
    Serial.print(&quot; &quot;);
    Serial.println(f2);

//also tested this way and it works too
    Serial.println(String(f0) + &quot; &quot; + String(f1) + &quot; &quot; + String(f2));
  } else {
    // I was coding here thinking its Boolean before
    //error
  }
</code></pre>
