Custom Formatters List For Server Connect 0.1

Several formatters are available to use Wappler more flexibly and more powerfully. I will be constantly updating the list and I will be completing different modules soon. You can write the PHP formatters you want here.

Serialize
(PHP 4, PHP 5, PHP 7)
serialize — Generates a storable representation of a value

UnSerialize
(PHP 4, PHP 5, PHP 7)
unserialize — Creates a PHP value from a stored representation

xml2json
(PHP 4, PHP 5, PHP 7)
simplexml_load_string — Interprets a string of XML into an object
(Other modules and formatters will be added for xml.)

JSON encode
(PHP 5 >= 5.2.0, PHP 7, PECL json >= 1.2.0)
json_encode — Returns the JSON representation of a value

JSON decode
(PHP 5 >= 5.2.0, PHP 7, PECL json >= 1.2.0)
json_decode — Decodes a JSON string

I haven’t added it to github yet, it will be added soon.

extensions.zip (1.4 KB)

11 Likes

I was wanting to explore the world of Custom Formatters and so uploaded these files to

[mydomain]\extensions\server_connect\formatters\custom.php
[mydomain]\extensions\server_connect\formatters\myformatter.hjson

which is at the same level as

[mydomain]\dmxAppConnect
[mydomain]\dmxConnect
[mydomain]\etc

but I am getting an error

message: "Formatter encodeJSON does not exist."

when I use it in a Server Action

image

What am I doing wrong?

How did you end up adding: encodeJSON() to the expression?

I downloaded the extensions.zip file to the directories mentioned above.

Then I went to the Database Insert Query and using the Data Picker for $_POST as shown here

Are you sure it should not be .json_encode()?

I am not sure at all.

All I did was to download the extension and pick it. Then I got the error. No instructions given so not sure what I was doing.

Probably @s.alpaslan should review his code and test it before uploading here :slight_smile:

hello @UKRiggers , @Teodor
I’m updating it soon. yes now i noticed the error. Please give me 20 minutes.

1 Like

Thanks for the pointer @Teodor, that did it.

I changed these few lines of code to the following and it worked

  {
    type: 'method_json_encode',
    groupTitle : 'Custom Formatters',
    groupIcon : 'fa fa-lg fa-key',
    addTitle: 'Encode JSON',
    title : 'Encode JSON',
    icon : 'fa fa-lg fa-font',
    state : 'opened',
    help : 'json_encode — Returns the JSON representation of a value',
    properties : []
  },
  {
    type: 'method_json_decode',
    groupTitle : 'Custom Formatters',
    groupIcon : 'fa fa-lg fa-key',
    addTitle: 'Decode JSON',
    title : 'Decode JSON',
    icon : 'fa fa-lg fa-font',
    state : 'opened',
    help : 'json_decode — Decodes a JSON string',
    properties : []
  }

and

function formatter_json_decode($val){
    return json_decode($val,true);
}

function formatter_json_encode($val){
    return json_encode($val,true);
}

Custom Formatters List For Server Connect 0.2

Serialize
(PHP 4, PHP 5, PHP 7)
serialize — Generates a storable representation of a value

UnSerialize
(PHP 4, PHP 5, PHP 7)
unserialize — Creates a PHP value from a stored representation

xml2json
(PHP 4, PHP 5, PHP 7)
simplexml_load_string — Interprets a string of XML into an object
(Other modules and formatters will be added for xml.)

JSON encode
(PHP 5 >= 5.2.0, PHP 7, PECL json >= 1.2.0)
json_encode — Returns the JSON representation of a value

JSON decode
(PHP 5 >= 5.2.0, PHP 7, PECL json >= 1.2.0)
json_decode — Decodes a JSON string

Intersect Array
(PHP 4 >= 4.0.1, PHP 5, PHP 7, PHP 8)

extensions.zip (142.4 KB)

4 Likes