When working with JSON format please note: Currently, wpDataTables accepts this, and only this, format of JSON (see example): a one-level array of same-structured objects where each object will be parsed as a row, and each field inside of the object as a cell. If your software does not return this format, you would need to prepare, as an example some PHP adapter to return one of the formats that wpDataTables would accept. Show
The JSON (JavaScript Object Notation) format was first introduced as a simple way to serialize and stringify objects or arrays for use in JavaScript snippets. JSON eventually proved to be so convenient, that it became wide-spread, and used as a standard for various web services. Many online platforms can return data in this format, and it is easy to generate it manually in most programming languages used in the web. wpDataTables also supports the JSON format as an input data source. In this example, we will use a sample JSON file with data for 100 imaginary employees. You can download this file for re-use via this link. For security reasons, WordPress only allows certain file types to be uploaded through the WordPress Admin Dashboard by default. We’ll go over what MIME file types are, which ones WordPress doesn’t restrict, and a few ways to remove the restriction and enable the uploading of JSON files (and any additional types). Table of ContentsWhat are MIME File Types?A Multipurpose Internet Mail Extensions type is a standard way of data type classification used with web technology, such as browsers, to determine how the file will be handled. A MIME type is made of two parts – a type and subtype, separated by a ‘/’. Some common MIME types are ‘application/json’ , ‘image/png’, and ‘text/html’. A use-case example is how the browser would determine by a .png file’s MIME type that it must be handled as an image file type, and not as any other file type, such as audio or video. MIME File Types WordPress Allows by DefaultAudio
Documents
Images
Videos
Ways to Upload JSON to WordPressBelow are a few different ways we can tell WordPress to allow JSON uploads: Allow JSON File Uploads via a PluginThis is the most straight-forward approach, especially if you don’t want to edit any code. WP Add Mime Types
|