JSONp reference

JSONp main functions

group JSONp

Enums

enum JSONpEncoder

JSONpEncoder. Encoder types handled by JSONp

Values:

enumerator JpASN1

Default internal ASN1 encoder

enumerator GnuASN1

GNU Libtasn

enumerator libBSON

LibBSON

Functions

int JSONp_Pack(JSONpArgs *jsonp_args)

Reads a text file and extracts JSON records for packing.

Parameters

jsonp_args – Pointer to the command-line arguments

Returns

int Exit code

int JSONp_ProcessRecord(cJSON *record, apr_hash_t *dict, JSONpArgs *jsonp_args, apr_pool_t *mp)

Process a JSON record and assigns a numeric key.

Parameters
  • record – cJSON object containing a record

  • dict – ARP dictionary to store key-value (string-int) pairs

  • jsonp_args – Pointer to the command-line arguments

  • mp – Pointer to an Apache Runtime memory pool

Returns

int Exit code

int JSONp_EncodeRecord(apr_hash_t *dict, cJSON *record, JSONpArgs *jsonp_args, Asn1Array *encValue, Asn1Array *keyEnc)

Encodes a JSON record and the corresponding numeric keys in binary format.

For a given JSON record, splits each key-value pair into an encValue pair, where the keys are replaced by numeric pre-assigned values, and a keyEnc pair, with a mapping between the original keys and the new encoded keys.

Parameters
  • dict – Dictionary (hash table) where the entries are the keys and the values are the encrypted keys

  • record – JSON object (key value pairs)

  • jsonp_args – JSONp command-line arguments

  • encValue – Pointer to an Asn1Array containing the resulting numeric key : value binary encoding

  • keyEnc – Pointer to an Asn1Array containing the resulting key : numeric key binary encoding

Returns

int return status

int JSONp_PrintEncoding(apr_hash_t *dict, const cJSON *record, JSONpArgs *jsonp_args)

Prints the record encoding (encoded record and dictionary)

Parameters
  • record – The cJSON object containing a record

  • dict – The ARP dictionary with key-value (string-int) pairs

  • jsonp_args – Pointer to the program’s options structure

Returns

int exit code

int JSONp_PrintDict(apr_hash_t *dict)

Prints the full dict.

Parameters

dict – The ARP dictionary with the key-value (string-long) pairs

Returns

int exit code

void JSONp_UpdateDict(apr_hash_t *dict, const cJSON *record, JSONpArgs *jsonp_args, apr_pool_t *mp)

Add the keys of a JSON record to a hash-table.

Remark

Existing keys are not overwritten.

Parameters
  • dict – ARP dictionary to store key-value (string-int) pairs

  • record – cJSON object containing a record

  • jsonp_args – Pointer to the command-line arguments

  • mp – Pointer to an Apache Runtime memory pool

Returns

int Exit code

int JSONp_cJSON_print(const cJSON *record, JSONpArgs *jsonp_args)

Prints the JSON object which holds a single record.

Parameters
  • record – cJSON object containing the record

  • jsonp_args – Pointer to the program’s options structure

Returns

int exit code

JSONp ASN.1 interface

group JSONp_ASN1

Definitions related to ASN.1 encoder

Defines

JSONP_ASN1_SUCCESS

ASN1 Encoding sucess

JSONP_ASN1_MEM_ERROR
JSONP_ASN1_FILE_WRITE_ERROR
ASN1_ARRAY_BLOCK_SIZE

Functions

int JSONp_ASN1EncodeRecord(const cJSON *record, apr_hash_t *dict, JSONpArgs *jsonp_args, Asn1Array *encValue, Asn1Array *keyEnc)

Asn1Array_AN1Encode Encodes a JSON record and its dictionarys keys in ASN.1 der binary format

The enconding of the encValue array in ASN.1 DER is as follows

Remark

When enconding the dictionary, only the elements present in the dictionary are encoded, as the dicionary may contain elements of another records.

DEFINITIONS ::= BEGIN

EncValue ::= SEQUENCE OF SEQUENCE {
    enc INTEGER,
    value CHOICE {
        int INTEGER,
        str UTF8String,
        bool BOOLEAN
    }
}

KeyEnc ::= SEQUENCE OF SEQUENCE {
    key UTF8String,
    enc INTEGER
}

Parameters
  • record – JSON object (key value pairs)

  • dict – Dictionary (hash table) where the entries are the keys and the values are the encrypted keys

  • jsonp_args – JSONp command-line arguments

  • encValue – Pointer to an Asn1Array containing the resulting numeric key : value binary encoding

  • keyEnc – Pointer to an Asn1Array containing the resulting key : numeric key binary encoding

Returns

int return status

int Asn1Array_Init(Asn1Array *array, unsigned char *name, unsigned char *suffix)

Asn1Array_Init Initializes the struct Asn1Array

Note

The string name followed ‘-’ and the tag defines the array’s suffix,

Parameters
  • array – Asn1Array array

  • name – Optional name to assign to the array (NULL if none)

  • suffix – Optional tag to assign to the array (NULL if none)

Returns

status Initialization results

int Asn1Array_Clear(Asn1Array *array)

Asn1Array_Clear Clear the struct Asn1Array

Parameters

array – Asn1Array array

Returns

int cleanup results

int Asn1Array_Print(Asn1Array *array, char *message)

Asn1Array_Print Print the array’s internal bytes

Parameters
  • array – Asn1Array array

  • message – Additional header message

Returns

int status

int Asn1Array_Insert(Asn1Array *array, enum ASN1_Type type, void *value)

Asn1Array_Insert Insert a simple ASN.1 element into an Asn1Array

Parameters
  • array – Asn1Array array

  • type – element’s type

  • value – element’s value

Returns

int return status

int Asn1Array_AppendPair(Asn1Array *array, enum ASN1_Type first_type, void *first_value, enum ASN1_Type second_type, void *second_value)

Asn1Array_AppendPair Appends a pair of ASN.1 elements into an existing Asn1Array

Note

A pair is modeled as an SEQUENCE ASN1 tag with two elements.

Parameters
  • array – Asn1Array array to append

  • first_type – First element’s type

  • first_value – First element’s value

  • second_type – Second element’s type

  • second_value – Second element’s value*

Returns

status return status

unsigned char MinSignedIntLength(int number)

Return the minimum number of bytes needed to represent a signed integer

Parameters

number – Signed integer

Returns

minimum number of bytes to represet the number

int Asn1Array_WriteToFile(Asn1Array *array, JSONpArgs *jsonp_args)

Write an binary Asn1Array to a file

Parameters
  • array – Asn1Array

  • jsonp_args – JSONp command-line arguments

Returns

int Exit status