Print

Step 2: Using the Data

Once you’ve fetched data from the data source, you’ll want to use it.
The basic considerations here are:

  • What data does the data source provide?
    If it is valid JSON, we can continue.
    But what if we get invalid JSON, XML, or CSV?
    The free version of the plugin only works with valid JSON!
    The PRO Plugin can repair invalid JSON and convert XML and CSV to valid JSON.
    JSON Example:
{ "aaaa": 
   {
     "bbbb": "valbbbb",
     "cccc": "valcccc"
   }
}
  • How is the JSON structured?
    You should be familiar with the basic structures of JSON files: objects, arrays, etc. – or become familiar with using the JCI-Plugins.
  • Using JSON with templates:
    The JCI Plugin formats JSON data with a template.
    The template must know what to do with the JSON to display the output.
  • The free JCI Plugin is pretty straightforward, adding JSON + template:
    It loops through the JSON and checks what commands the template gives. Those commands are the JCI parser commands. The result is HTML content for the website.
    Shortcode example with free JCI-Plugin:
[jsoncontentimporter url=https://api.json-content-importer.com/extra/json-examples/jci-step.json basenode=aaaa]
{bbbb} and {cccc}
[/jsoncontentimporter]
  • The PRO Plugin is the same as the free plugin but much more powerful:
    • It uses the twig parser, which is way more powerful than the JCI parser.
    • You have full control of the template for sending other data source requests, manipulating data, and accessing page properties like logged-in users.
      Shortcode example with PRO JCI-Plugin:
[[jsoncontentimporterpro url=https://api.json-content-importer.com/extra/json-examples/jci-step.json debugmode=10 parser=twig]
{{aaaa.bbbb}} and {{aaaa.cccc}}
[/jsoncontentimporterpro]]

The better way to have a JCI-Template: Add one and name it “NUMBER_OF_TEMPLATE” plus adding URL etc..
Then use this Shortcode:

[jsoncontentimporterpro nameoftemplate=NUMBER_OF_TEMPLATE]

Common errors:
avoid/remove any linefeeds in the No URL defined: Check the shortcode - one typical error: is there a blank after url= ? statements. Linefeeds can cause the shortcode-parameter is not available, and the plugin lacks the needed information.
– when using the template-manager use only [jsoncontentimporterpro url=… id=…] and do NOT add [/jsoncontentimporterpro]. If this is there, the id=… is ignored.
– quotation marks are a common trouble source: The best way is not to use quotation marks (works as long there is no blank space in the parameter. Also: When copypasting code, sometimes the “wrong” quotation marks are inserted, and WordPress gets confused. Ok are single (‘) and double (“) quotation marks. Problematic are other like “, ”, „, “

Was this article helpful?
0 out Of 5 Stars
5 Stars 0%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.
On this page: