# How to create nutrition app with ocr scanner?

**URL:** <https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955>\
**Category:** Questions about Thunkable X\
**Created:** [February 21, 2021, 5:28pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955 "2021-02-21T17:28:00Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 1, 2021, 12:44pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/42 "2021-03-01T12:44:35Z")

</div>

I want the nutrition value from the json property to display in the text.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 1, 2021, 5:14pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/43 "2021-03-01T17:14:55Z")

</div>

I’m not seeing that property in the JSON response. Is it possible for you to paste the JSON response text into a [JSON Formatter](https://jsonformatter-online.com/) and then post a screenshot of the section that contains the “nutrition” property. I may have missed it. I’m also not seeing a property called “healthy/unhealthy” so if you can include that, it would be helpful.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 1, 2021, 5:25pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/44 "2021-03-01T17:25:54Z")

</div>

![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/3/a/3a960916dd403b750a25c245d0269211c6a7a1ab.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 1, 2021, 5:54pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/45 "2021-03-01T17:54:58Z")

</div>

In the [post above](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/34), I provided a screenshot of formatted JSON. That’s what I’m referring to.

For example, in that screenshot there are properties called “countries” and “nutrition\_data\_per”.

I’m wondering where you found the “nutrition” and “healthy/unhealthy” fields/properties. Those text strings have to exactly match pieces of data that exists in the JSON response from the API server.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 1, 2021, 6:07pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/46 "2021-03-01T18:07:35Z")

</div>

Oh okay! I think I got confused while inserting the information.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/2/5/25eda8683ee3b620bb6c60f0be94d858720335c8.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 1, 2021, 6:39pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/47 "2021-03-01T18:39:27Z")

</div>

Is it working now?

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 1, 2021, 6:47pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/48 "2021-03-01T18:47:25Z")

</div>

No its not working. When I connected to my phone and tried it just said that there was something wrong with the blocks.

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 1, 2021, 7:01pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/49 "2021-03-01T19:01:15Z")

</div>

Did you enter the full url including barcode into a browser such as Chrome? Something like this:

[https://world.openfoodfacts.org/api/v0/product/856904000376.json](https://world.openfoodfacts.org/api/v0/product/856904000376.json)

And did you then copy the result into a JSON Formatter website? That would look like this:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/3/b3b8da272e6f8e88ac91c1296861cf80706ba434.png)

If so, you can look down the list for properties you want to Get and then I can help you. I’m not seeing “countries.” I know I suggested that but it may be that different products have different JSON results…? That can make things a little tricky sometimes.

**Post a screenshot like that showing the properties you want on the right side** and I can help you figure out the format for your blocks.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 1, 2021, 7:33pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/50 "2021-03-01T19:33:28Z")

</div>

The url was correct so I put it in the json formatter:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/4/b4dc25340644561c82223820f4624512557a0ae5.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 1, 2021, 7:52pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/51 "2021-03-01T19:52:33Z")

</div>

And what is the actual url you used?

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 1, 2021, 8:09pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/52 "2021-03-01T20:09:29Z")

</div>

[https://world.openfoodfacts.org/api/v0/product/737628064502.json](https://world.openfoodfacts.org/api/v0/product/737628064502.json)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 1, 2021, 8:53pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/53 "2021-03-01T20:53:38Z")

</div>

Okay. The JSON response you posted from that URL has the value: “France, United States” for the property “countries” (near the bottom of the screenshot). Is that the one you’re interested in?

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 1, 2021, 9:31pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/54 "2021-03-01T21:31:00Z")

</div>

Yes

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 1, 2021, 11:35pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/55 "2021-03-01T23:35:22Z")

</div>

These are the blocks you would use in the Web API “Get” block to get the value “France, Unites States”:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/4/c/4cef0a2fcd5948f4112cb04a42a8966d66d2683c.png)

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 2, 2021, 12:24am UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/56 "2021-03-02T00:24:28Z")

</div>

Is this correct?

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/b/7b76c9c66b1b3d73bcd831138b7c71550e3a1fc4.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 2, 2021, 12:27am UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/57 "2021-03-02T00:27:54Z")

</div>

No. You have to study the formatted JSON to see what value you want and then work backwards (out and up) from that property to the top.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 2, 2021, 12:46am UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/58 "2021-03-02T00:46:36Z")

</div>

How about this? I fixed the properties.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/b/c/bca4c32b552184b58058f44c6053510581135a32.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 2, 2021, 4:28am UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/59 "2021-03-02T04:28:15Z")

</div>

You only need to “get object from JSON” once. Remove it from the last set of blocks. See my screenshot above for a comparison. Once you do that, it should work.

---

<div class="post-metadata">

**Author:** ![celebytes20212iy4](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@celebytes20212iy4](https://community.thunkable.com/u/celebytes20212iy4)\
**Post date:** [March 2, 2021, 8:24pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/60 "2021-03-02T20:24:31Z")

</div>

These are my blocks. But it is still not working.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/9/b/9bb060c34a698bbc8850460deaa317facb3fbbda.png)

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [March 2, 2021, 8:39pm UTC](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955/61 "2021-03-02T20:39:56Z")

</div>

I think you’re close! It’s helpful to explain what happens when you try to run certain code. So instead of just saying it’s not working… what was the result? Do you get a “something’s not right” white screen? If you set a label component to the Web API’s green error block, what is the value of that block? In your Main label component, does anything appear? How are you verifying that the barcode value is what you expect it to be? You need to check the green error block value for the Barcode Scanner component, too. And I would recommend setting a separate label’s value to the green value block so you can make sure that’s working as well.

If you still can’t get it to work, share the following:

1. The value of the barcode scanner’s “value” block and green “error” block
2. The value of the web API’s green “error” block
3. The expected value for the Main label’s text (if everything _was_ working right)

[Previous page](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955.md?page=2)

[Next page](https://community.thunkable.com/t/how-to-create-nutrition-app-with-ocr-scanner/1113955.md?page=4)
