GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Search::Elasticsearch::Role::Serializer::JSON(3) User Contributed Perl Documentation Search::Elasticsearch::Role::Serializer::JSON(3)

Search::Elasticsearch::Role::Serializer::JSON - A Serializer role for JSON modules

version 6.00

This role encodes Perl data structures into JSON strings, and decodes JSON strings into Perl data structures.

    $bytes = $serializer->encode($ref);
    $bytes = $serializer->encode($str);

The "encode()" method converts array and hash refs into their JSON equivalents. If a string is passed in, it is returned as the UTF8 encoded version of itself. The empty string and "undef" are returned as is.

    $bytes = $serializer->encode_pretty($ref);
    $bytes = $serializer->encode_pretty($str);

Works exactly as "encode()" but the JSON output is pretty-printed.

    $bytes = $serializer->encode_bulk([\%hash,\%hash,...]);
    $bytes = $serializer->encode_bulk([$str,$str,...]);

The "encode_bulk()" method expects an array ref of hashes or strings. Each hash or string is processed by "encode()" then joined together by newline characters, with a final newline character appended to the end. This is the special JSON format used for bulk requests.

    $var = $serializer->decode($json_bytes);
    $str = $serializer->decode($bytes);

If the passed in value looks like JSON (ie starts with a "{" or "[" character), then it is decoded from JSON, otherwise it is returned as the UTF8 decoded version of itself. The empty string and "undef" are returned as is.

Clinton Gormley <drtech@cpan.org>

This software is Copyright (c) 2017 by Elasticsearch BV.

This is free software, licensed under:

  The Apache License, Version 2.0, January 2004
2017-11-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.