Ejemplo n.º 1
0
 public function __construct($status, $username, $data)
 {
     $json = new json();
     $json->add('Status', $status);
     $json->add('Username', $username);
     $json->add('UserData', $data);
     $json->add('Success');
     $this->json = $json->make();
 }
Ejemplo n.º 2
0
<?php

// The only include you need
include '../includes/json.php';
// Create a raw JSON
$json = new json();
// Define objects to send
$object = new stdClass();
$object->FirstName = 'John';
$object->LastName = 'Doe';
$array = array(1, '2', 'Pieter', true);
$jsonOnly = '{"Hello" : "darling"}';
// Add objects to send
$json->add('status', '200');
$json->add("worked");
$json->add("things", false);
$json->add('friend', $object);
$json->add("arrays", $array);
$json->add("json", $jsonOnly, false);
/*
  Expected result : 
  {
    "status": "200",
    "worked": true,
    "things": false,
    "friend": {
        "FirstName": "John",
        "LastName": "Doe"
    },
    "arrays": [
        1,