<?php
namespace ccxt;

// ----------------------------------------------------------------------------

// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code

// -----------------------------------------------------------------------------


function test_json() {
    $exchange = new \ccxt\Exchange(array(
        'id' => 'regirock',
    ));
    // Test: object
    $obj = array(
        'k' => 'v',
    );
    $obj_json = $exchange->json($obj);
    assert($obj_json === '{"k":"v"}');
    // Test: list
    $list = [1, 2];
    $list_json = $exchange->json($list);
    assert($list_json === '[1,2]');
    assert('GO_SKIP_START');
    try {
        throw new BadRequest('some error');
    } catch(\Throwable $e) {
        $err_string = $exchange->json($e);
        assert($err_string === '{"name":"BadRequest"}');
    }
    assert('GO_SKIP_END');
    // Test: json a string
    $str = 'ccxt, rocks!';
    $serialized_string = $exchange->json($str);
    assert($serialized_string === '"ccxt, rocks!"');
}
