jaisocx / objdata
ObjData format for objects and arrays in old good style of packets with fixed lengths and offsets fields.
Installs: 12
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/jaisocx/objdata
Requires
- php: >=8.2
This package is not auto-updated.
Last update: 2026-01-13 00:20:29 UTC
README
ObjData format for objects and arrays in old good style of packets with fixed lengths and offsets fields.
- npm install
- composer install
related URLs
See in action:
https://workspace.brightday.email/ExampleSimple_ObjDataByPhpEndpoint.html
SourceCode
Related OpenSource
- PHP Composer lib: https://github.com/Jaisocx-Tools/objdata_php
- PHP example ObjData usage: https://github.com/Jaisocx-Tools/Workspace/tree/main/code/php/objdata_example
- JS ObjData lib: https://github.com/Jaisocx-Tools/Workspace/tree/main/code/ts/www/packages/ObjData
- How to get ObjData with JS in a web browser: https://github.com/Jaisocx-Tools/Workspace/tree/main/code/ts/www/packages/Api
- Jaisocx-Tools repos: https://github.com/orgs/Jaisocx-Tools/repositories
- Jaisocx-Tools for TypeScript and JavaScript development, "Workspace" repo: https://github.com/Jaisocx-Tools/Workspace
Parser, ObjData to PHP Array
use Jaisocx\ObjData\ObjData;
$odFileContent = file_get_contents( "/some-path/data.od" );
$bitsBuf = unpack('C*', $odFileContent);
$phpArray = ObjData::parse( $bitsBuf );
Serializer, PHP Array to ObjData
use Jaisocx\ObjData\ObjData;
$phpArray = [
"message" => "Hello World",
];
$objdata = ObjData::serialize( $phpArray );
header("Content-Type: application/objdata", true);
header("Content-Disposition: inline", true);
header("Content-Encoding: gzip", true);
echo gzencode( $objdata );
How to develop in TypeScript or JavaScript for use in web browsers
npm install
npm install @jaisocx/objdata
Basic usage
import { ObjData } from "@jaisocx/objdata";
const obj: any = ObjData.parse( objdataFormattedBytebuf );
Basic usage from a remote URL.
fetch( "https://example.com/some-url/data.od" )
.then( ( response: Response ): Promise<ArrayBuffer> => {
return response.arrayBuffer();
})
.then( ( buf: ArrayBuffer ): any => {
let objdata: Uint8Array = new Uint8Array( buf, 0, buf.byteLength );
// obtaining JS object or array.
let obj: any = ObjData.parse( objdata );
return obj;
});