# Transform JSON with JQ

**URL:** <https://community.glideapps.com/t/transform-json-with-jq/56088>\
**Category:** Ask for Help\
**Created:** [December 27, 2022, 3:25pm UTC](https://community.glideapps.com/t/transform-json-with-jq/56088 "2022-12-27T15:25:17Z")\
**Posts on this page:** 7\
**Page:** 2

<div class="post-metadata">

**Author:** ![bjgray](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/bjgray/32/50137_2.png) [@bjgray](https://community.glideapps.com/u/bjgray)\
**Post date:** [December 28, 2022, 8:52pm UTC](https://community.glideapps.com/t/transform-json-with-jq/56088/21 "2022-12-28T20:52:25Z")

</div>

Big “THANK YOU” to each of you. This was a challenge I’d been struggling with for several days. It’s working exactly as I’d wanted now.

 ![Screen Shot 2022-12-28 at 3.46.46 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/d/8d38946c3d364d05e34e0805324ae7113f0d0215.png)

---

<div class="post-metadata">

**Author:** ![bjgray](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/bjgray/32/50137_2.png) [@bjgray](https://community.glideapps.com/u/bjgray)\
**Post date:** [December 28, 2022, 8:52pm UTC](https://community.glideapps.com/t/transform-json-with-jq/56088/22 "2022-12-28T20:52:46Z")

</div>

![Screen Shot 2022-12-28 at 3.45.53 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/b/eb0fb811565232cfb3d31fc7bdda80995550a00d.png)

---

<div class="post-metadata">

**Author:** ![Uzo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/uzo/32/22639_2.png) [@Uzo](https://community.glideapps.com/u/Uzo)\
**Post date:** [December 28, 2022, 9:56pm UTC](https://community.glideapps.com/t/transform-json-with-jq/56088/23 "2022-12-28T21:56:20Z")

</div>

so…what was the problem, and what solution?

---

<div class="post-metadata">

**Author:** ![bjgray](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/bjgray/32/50137_2.png) [@bjgray](https://community.glideapps.com/u/bjgray)\
**Post date:** [December 28, 2022, 10:33pm UTC](https://community.glideapps.com/t/transform-json-with-jq/56088/24 "2022-12-28T22:33:07Z")

</div>

The problem was how to parse only the data i needed from a JSON string and place each piece into separate columns. The Transform JSON function wasn’t working but @Darren_Murphy’s JavaScript technique along with your tweak worked perfectly once I figured out how to use the P2 field in the JavaScript column.

 ![Screen Shot 2022-12-28 at 5.23.47 PM](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/f/a/facc38e05e914d5583e5619e0fea957d16555bfb.png)

---

<div class="post-metadata">

**Author:** ![gvalero](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/gvalero/32/1037_2.png) [@gvalero](https://community.glideapps.com/u/gvalero)\
**Post date:** [December 28, 2022, 11:12pm UTC](https://community.glideapps.com/t/transform-json-with-jq/56088/25 "2022-12-28T23:12:46Z")

</div>

Ok… thanks again!

Let’s play some scenarios in order to be more efficient if the circunstancies allow it:

1. how many rows (bookings) does your table have? Let’s assume that it has 2,000 rows.  
if your APP is used by 5 users and each one opened it 3 times in 1 hour to see the charges, did your management system API have to handle 30,000 requests in 1 hour?  
It’s too much data and work according to my point of view.

2. Wouldn’t it be better to parse the JSON payload only when the user presses the details screen?  
I mean, the user sees the customer list from your APP, if he wants to see a specific charge list belonging to a customer, the APP will load and show the Details screen and from this point on, your app will fire an API call requesting data from that specific customer and then parse the JSON payload putting that information into multiple columns (as many as you want).

Probabilistically (I think), your API must work 1-2% only in this case and your APP should be faster.

I hope it helps, have a nice night.

Saludos!

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [December 29, 2022, 2:36am UTC](https://community.glideapps.com/t/transform-json-with-jq/56088/26 "2022-12-29T02:36:31Z")

</div>

> [@bjgray](#):
>
> worked perfectly once I figured out how to use the P2 field in the JavaScript column.

If you’re hard coding the `p2` value, then you don’t need to bother using it at all.  
ie. in the example you gave, you could just write:

```auto
return json[1].amount;

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [December 30, 2022, 2:37am UTC](https://community.glideapps.com/t/transform-json-with-jq/56088/27 "2022-12-30T02:37:01Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

[Previous page](https://community.glideapps.com/t/transform-json-with-jq/56088.md?page=1)
