Numbers and Strings in free and PRO plugin

Numbers and Strings:
See this JSON:
{"num": 3.5050, "str": "3.4040" }
There is a little difference: “num” is without quotation marks, “str” is with. The JSON Content Importer Plugin and the PHP behind that handles the “num” as numeric data and removes the 0 at the end.
Free jsoncontentimporter:
[jsoncontentimporter url=http://api.json-content-importer.com/extra/json/number.json]num: {num}, str: {str}[/jsoncontentimporter]
gives us this:
num: 3.505, str: 3.4040
To “save” the 0 you need the PRO plugin – unfortunately: There “convertjsonnumbers2strings=yes” converts the JSON to do this.
[jsoncontentimporterpro url=http://api.json-content-importer.com/extra/json/number.json convertjsonnumbers2strings=yes parser=twig] {{num}} {{str}}[/jsoncontentimporterpro]
gives us this:
num: 3.5050, str: 3.4040

PRO-Plugin: API Zippopotamus

The API http://zippopotam.us/ gives Citynames and Coorindates to a Zipcode. The JCI-PRO-Plugin can use that for a “Zipcode to City-Search”:


Examples: Houston, US, TX | Munich, DE, Germany
This done this way:

1 .JCI-Template:

[jsoncontentimporterpro id=ID_OF_TEMPLATE httpstatuscodemustbe200=no]

2. twig-template:

  • url:
    http://api.zippopotam.us/{% if urlparam.co %}{{urlparam.co}}{% else %}US{% endif %}/{% if urlparam.zip %}{{urlparam.zip}}{% else %}80636{% endif %}
  • urlparam4twig: zip#co
  • twig-code (“/zippopotamus/” is the URL to the WordPress-Page with the Shortcode):
    {% if urlparam.co %}{% set coun = urlparam.co %}{% else %}{% set coun = "US" %}{% endif %}
    <form action=/zippopotamus/>
    <select name="co" id=jciinput>
    <option value="DE" {% if coun =="DE" %}selected{% endif %}>Germany</option>
    <option value="US" {% if coun =="US" %}selected{% endif %}>United States</option>
    </select>
    <input type=text name=zip placeholder="Insert Zipcode" value="{% if urlparam.zip %}{{urlparam.zip}}{% else %}80636{% endif %}">
    <input type=submit id=jciinput value="Search Zipcode for City">
    </form>
    <hr>
    {% if places %}
    <strong>Found:</strong><br>
    <ol>{% for p in places %}<li>
    <a href="https://www.google.com/maps/search/{{p.latitude}},{{p.longitude}}" target="_blank">{{ attribute(p, 'place name') }} ({{ attribute(p, 'state abbreviation') }})</a>
    </li>{% endfor %}</ol>
    {% else %}
    no City to this Zipcode {{urlparam.zip}} found
    {% endif %}
    <style>
    #jciinput {
        border-radius: 5px;
        width: 320px;
        height:35px;
        background: #eee;
     color: black;
    }
    </style>
    <hr>
    Examples: <a href="/zippopotamus/?co=US&zip=77004">Houston, US, TX</a> | 
    <a href="/zippopotamus/?co=DES&zip=80636">Munich, DE, Germany</a>
    

PRO JCI Plugin and the API of openweathermap.org

The API of openweathermap.org gives Feeds like https://samples.openweathermap.org/ and inside that JSON like https://samples.openweathermap.org/data/2.5/weather?q=London&appid=…

This can be used by the PRO JSON Content Importer Plugin for searching the weather:

For that xyou need a Shortcode and a JCI-Template.


1. The Shortcode:

[jsoncontentimporterpro id=ID_OF_TEMPLATE httpstatuscodemustbe200=no]

is all you need as Shortcode on a WordPress-Page, – Post or CPT.
“httpstatuscodemustbe200=no” is required, as the API answers with an http-Error when a place can’t be found.

2. The JCI-Template:

Continue reading “PRO JCI Plugin and the API of openweathermap.org”

Free JCI Plugin: Data from playlist with basenode and without

JSON: https://cast02.siamsa.ie/public/radio_siamsa/api/live/nowplaying/radio_siamsa
Solution:
[jsoncontentimporter url=https://cast02.siamsa.ie/public/radio_siamsa/api/live/nowplaying/radio_siamsa basenode=now_playing.song] {text}<img src={art}> [/jsoncontentimporter]
or:
[jsoncontentimporter url=https://cast02.siamsa.ie/public/radio_siamsa/api/live/nowplaying/radio_siamsa] {subloop:now_playing:-1} {subloop:now_playing.song:-1} {now_playing.song.text}<img src={now_playing.song.art}> {/subloop:now_playing.song} {/subloop:now_playing} [/jsoncontentimporter]

Books: Current Bestseller

With the free JSON Content Importer Plugin you can display the New York Times Bestseller-Booklist:

Code for that:
[jsoncontentimporter url=https://api.nytimes.com/svc/books/v3/lists/current/hardcover-fiction.json?api-key=YOUR_NYT_API_BOOK_KEY basenode=results] {list_name}<br>{subloop-array:books:-1}<img src="{books.book_image}" title="{books.title}" align="left" width="40" hspace="5"> {books.rank}. <a href="{books.amazon_product_url}" target="_blank">{books.title}</a><br>{books.description}<br clear="all"> <hr>{/subloop-array:books} [/jsoncontentimporter]


In action:

Hardcover Fiction
1. WHERE THE CRAWDADS SING
In a quiet town on the North Carolina coast in 1969, a young woman who survived alone in the marsh becomes a murder suspect.


2. HIDEAWAY
A child star escapes her abductors, gathers herself in western Ireland and returns to Hollywood.

3. FAIR WARNING
The third book in the Jack McEvoy series. A reporter tracks a killer who uses genetic data to pick his victims.

4. CAMINO WINDS
The line between fact and fiction becomes blurred when an author of thrillers is found dead after a hurricane hits Camino Island.

5. IF IT BLEEDS
Four novellas: “Mr. Harrigan’s Phone,” “The Life of Chuck,” “Rat” and “If It Bleeds.”

6. BIG SUMMER
Daphne Berg’s former best friend asks her to be the maid of honor at her wedding in Cape Cod.

7. AMERICAN DIRT
A bookseller flees Mexico for the United States with her son while pursued by the head of a drug cartel.

8. WALK THE WIRE
The sixth book in the Memory Man series. Decker and Jamison investigate a murder in a North Dakota town in a fracking boom.

9. ALL ADULTS HERE
A repressed memory triggers Astrid Strick to weigh the outcomes of her parenting of her now-grown children.

10. THE 20TH VICTIM
The 20th book in the Women’s Murder Club series. Lindsay Boxer looks into the murders of disreputable persons in three separate cities.

11. THE SILENT PATIENT
Theo Faber looks into the mystery of a famous painter who stops speaking after shooting her husband.

12. THE GIVER OF STARS
In Depression-era Kentucky, five women refuse to be cowed by men or convention as they deliver books.

13. THE BOOK OF LONGINGS
A scholarly young woman named Ana meets an 18-year-old Jesus and becomes caught up in a confluence of dangers.

14. WRATH OF POSEIDON
The 12th book in the Sam and Remi Fargo Adventure series. A kingpin is released from prison and a final showdown takes place in Greece.

15. THE LAST TRIAL
An 85-year-old defense lawyer puts off his retirement to aid a Nobel Prize winner in Medicine, who is accused of insider trading, fraud and murder.

JCI and casino.chompcasino.com

Challenge: Load https://casino.chompcasino.com/content/chomp-casino/json/2.1/manifest_multicurrency.json and display those game-items containing a defined title.

Solution: Create a new JCI-template with the following settings.
URL: https://casino.chompcasino.com/content/chomp-casino/json/2.1/manifest_multicurrency.json
urlparam4twig : t

Twig code in template:

{% set t = 'Mont' %}
{% if urlparam.t %}
{% set t = urlparam.t %}
{% endif %}
term: {{t}}<br>
{% for g in games if g.title matches '/'~t~'/i'  %}
title: {{g.title}}<br>
{% for i in g.images %}
{{i.url}}
{% endfor %}
<hr>
{% endfor %}

Create new page with this Shortcode: [jsoncontentimporterpro id=NUMBER_OF_JCI_TEMPLATE]

In Action:

Try also this: http://api.json-content-importer.com/jci-and-casino-chompcasino-com/?t=romance

term: Mont
title: Montezuma
/content/all/images/montezuma/banner.jpg /content/all/images/montezuma/tile.jpg

JCI and TablePress

The Plugin “TablePress” and the PRO version of the JSON Content Importer can work together in this way:

First: Create a new TablePress-Table with e. g. two columns and two rows. Fill the cells with some dummy text. This gives you a shortcode [table id=NUMBER_OF_TABLEPRESS_TABLE].

Second: Create a new JCI-Plugin Template with e. g. some JSON data. The Twig-Code is

name: {{_context.0.name}}
[table “NUMBER_OF_TABLEPRESS_TABLE” not found /]

Third: Create a new WordPress-Page/Post with
[jsoncontentimporterpro id=NUMBER_OF_JCI_TEMPLATE]

Preview this page: You should see some “name”-Data and a Table.

Then change the content of a Table-Cell and insert {{_context.0.name}} there.

Preview the page again: If you see the Twig-Code in the Tablecell go to the JCI-Plugin-Options, Tab Settings and select “first third-party-Shortcodes, 2nd: JSONContentImporter-Shortcode (use this for TablePress, Contact Form 7 etc.)”.

Preview again and you should see the JSON-data in the Table.

If the number of columns or rows is dynamic: Up to my knowleded TablePress has a fixed number of cols and rows. So this is not that flexible.
Maybe Table Sort is an option then.

JCI and Table Press in Action:

name: Love Breakfast
1a: {{_context.0.name}}1b
2a2b