HEX
Server: LiteSpeed
System: Linux houston.panomity.com 6.8.0-100-generic #100-Ubuntu SMP PREEMPT_DYNAMIC Tue Jan 13 16:40:06 UTC 2026 x86_64
User: nudepix (1011)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //opt/textanalyse/web_console/node_modules/jsonpath/test/stringify.js
var assert = require('assert');
var jp = require('../');

suite('stringify', function() {

  test('simple path stringifies', function() {
    var string = jp.stringify(['$', 'a', 'b', 'c']);
    assert.equal(string, '$.a.b.c');
  });

  test('numeric literals end up as subscript numbers', function() {
    var string = jp.stringify(['$', 'store', 'book', 0, 'author']);
    assert.equal(string, '$.store.book[0].author');
  });

  test('simple path with no leading root stringifies', function() {
    var string = jp.stringify(['a', 'b', 'c']);
    assert.equal(string, '$.a.b.c');
  });

  test('simple parsed path stringifies', function() {
    var path = [
      { scope: 'child', operation: 'member', expression: { type: 'identifier', value: 'a' } },
      { scope: 'child', operation: 'member', expression: { type: 'identifier', value: 'b' } },
      { scope: 'child', operation: 'member', expression: { type: 'identifier', value: 'c' } }
    ];
    var string = jp.stringify(path);
    assert.equal(string, '$.a.b.c');
  });

  test('keys with hyphens get subscripted', function() {
    var string = jp.stringify(['$', 'member-search']);
    assert.equal(string, '$["member-search"]');
  });

  test('complicated path round trips', function() {
    var pathExpression = '$..*[0:2].member["string-xyz"]';
    var path = jp.parse(pathExpression);
    var string = jp.stringify(path);
    assert.equal(string, pathExpression);
  });

  test('complicated path with filter exp round trips', function() {
    var pathExpression = '$..*[0:2].member[?(@.val > 10)]';
    var path = jp.parse(pathExpression);
    var string = jp.stringify(path);
    assert.equal(string, pathExpression);
  });

  test('throws for no input', function() {
    assert.throws(function() { jp.stringify() }, /we need a path/);
  });

});