Title: Do math on a JSON field
Last modified: November 13, 2018

---

# Do math on a JSON field

 *  Resolved [Duf](https://wordpress.org/support/users/duf/)
 * (@duf)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/do-math-on-a-json-field/)
 * One of the fields I am pulling in is a wait time value which is formatted in 
   seconds. Is there a way in the plug in to take that number, divide it by 60 and
   round it up to give the value in minutes instead?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [berkux](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/do-math-on-a-json-field/#post-10879183)
 * Hi duf,
 * The pro plugin can do this by using twig in the template:
    [https://twig.symfony.com/doc/2.x/filters/round.html](https://twig.symfony.com/doc/2.x/filters/round.html)
 * Bernhard
 *  Thread Starter [Duf](https://wordpress.org/support/users/duf/)
 * (@duf)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/do-math-on-a-json-field/#post-10879612)
 * I see the round function but what about dividing the value by 60 first?
 *  Plugin Author [berkux](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/do-math-on-a-json-field/#post-10879745)
 * See [https://twig.symfony.com/doc/2.x/templates.html](https://twig.symfony.com/doc/2.x/templates.html)
   
   At chapter math
 *  Thread Starter [Duf](https://wordpress.org/support/users/duf/)
 * (@duf)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/do-math-on-a-json-field/#post-10879771)
 * Ok I see. I am an absolute novice at this. How would an example line of twig 
   code look that takes a JSON field, divides it by 60 and then rounds it to the
   next number? Thanks in advance for any help you can offer, I have the plug in
   doing what I need I just need this last piece to get it formatted correctly.
 *  Thread Starter [Duf](https://wordpress.org/support/users/duf/)
 * (@duf)
 * [7 years, 6 months ago](https://wordpress.org/support/topic/do-math-on-a-json-field/#post-10880429)
 * I am so close I just can’t get this twig template to execute the math, otherwise
   it is pulling the data. My JSON data starts with [{ so I am doing it as you described.
 * {% for item in _context %}
    {{item.name}} <br> Customers Waiting: {{item.customersWaiting}}
   <br> ({% set wait_min= (waitingTime/60)|round %}Estimated wait time: {{wait_min}}
   minutes) <br> <br> {% endfor %}
 *  Plugin Author [berkux](https://wordpress.org/support/users/berkux/)
 * (@berkux)
 * [7 years, 5 months ago](https://wordpress.org/support/topic/do-math-on-a-json-field/#post-10896632)
 * Ok, we proceed on [https://jsoncontentimporter.freshdesk.com](https://jsoncontentimporter.freshdesk.com)

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Do math on a JSON field’ is closed to new replies.

 * ![](https://ps.w.org/json-content-importer/assets/icon-256x256.png?rev=3464653)
 * [Get Use APIs - JSON Content Importer](https://wordpress.org/plugins/json-content-importer/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-content-importer/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-content-importer/)
 * [Active Topics](https://wordpress.org/support/plugin/json-content-importer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-content-importer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-content-importer/reviews/)

 * 6 replies
 * 2 participants
 * Last reply from: [berkux](https://wordpress.org/support/users/berkux/)
 * Last activity: [7 years, 5 months ago](https://wordpress.org/support/topic/do-math-on-a-json-field/#post-10896632)
 * Status: resolved