Raised This Month: $105 Target: $400
 26% 

[ANY] yyjson 1.0.6a - Very fast JSON parsing


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ProjectSky
AlliedModders Donor
Join Date: Aug 2020
Old 06-25-2024 , 07:47   [ANY] yyjson 1.0.6a - Very fast JSON parsing
Reply With Quote #1

This extension that provides some methods for manipulating JSON data

Features
  • Relies on YYJSON which A high performance JSON library written in ANSI C
  • Supports querying and modifying using JSON Pointer
  • Supports iterate through arrays and objects
  • Supports decoding and encoding (also with pretty format)
  • Supports x64

Source Code: sm-ext-yyjson
Native: yyjson.inc
Binary files: GitHub Actions

Last edited by ProjectSky; 10-29-2024 at 12:49. Reason: upd
ProjectSky is offline
ProjectSky
AlliedModders Donor
Join Date: Aug 2020
Old 06-25-2024 , 07:47   Re: [any] yyjson 1.0.1 - Very fast JSON parsing
Reply With Quote #2

Examples

Create a JSON object
PHP Code:
YYJSONObject hJSONObject = new YYJSONObject();
hJSONObject.SetInt("int"1);
hJSONObject.SetInt64("int64""9223372036854775800");
hJSONObject.SetFloat("float"2.0);
hJSONObject.SetBool("bool"true);
hJSONObject.SetString("str""Hello World");
hJSONObject.SetNull("null");
delete hJSONObject;
/*
{
  "int": 1,
  "int64": 9223372036854775800,
  "float": 2.0,
  "bool": true,
  "str": "Hello World",
  "null": null
}
*/ 
Create a JSON array
PHP Code:
YYJSONArray hJSONArray = new YYJSONArray();
hJSONArray.PushInt(1);
hJSONArray.PushInt64("9223372036854775800");
hJSONArray.PushFloat(2.0);
hJSONArray.PushBool(true);
hJSONArray.PushString("Hello World");
hJSONArray.PushNull();
delete hJSONArray;
/*
[
  1,
  9223372036854775800,
  2.0,
  true,
  "Hello World",
  null
]
*/ 
JSON POINTER: Create a JSON object
PHP Code:
YYJSONObject hJSONObject = new YYJSONObject();
hJSONObject.PtrSetInt("/a/b/c"1);
delete hJSONObject;
/*
{
  "a": {
    "b": {
      "c": 1
    }
  }
}
*/ 
JSON POINTER: Query data
PHP Code:
/*
{
  "bool": true,
  "float": 1.234,
  "int": 1234,
  "int64": 9223372036854775807,
  "null": null,
  "string": "hello world",
  "arr": [
    false,
    1.2344,
    1234,
    9223372036854775807,
    null,
    "Hello World"
  ]
}
*/
hPtrTest.PtrGetInt("/int"); // 1234
hPtrTest.PtrGetFloat("/arr/1"); // 1.2344
delete hPtrTest
Iteration Objects
PHP Code:
char key[64];
YYJSON val;
for (
int i 0hPtrTest.Sizei++)
{
  
hPtrTest.GetName(ikeysizeof(key));
  
PrintToServer("key: %s"key);
  
val hPtrTest.GetValueAt(i);
  
// do something
  
delete val;

Iteration Arrays
PHP Code:
YYJSONArray arr hPtrTest.PtrGet("/arr");
YYJSON val;
for (
int i 0arr.Lengthi++)
{
  
val arr.Get(i);
  
// do something
  
delete val;
}
delete arr

Last edited by ProjectSky; 06-27-2024 at 07:38.
ProjectSky is offline
ProjectSky
AlliedModders Donor
Join Date: Aug 2020
Old 10-29-2024 , 12:51   Re: [ANY] yyjson 1.0.6a - Very fast JSON parsing
Reply With Quote #3

Updated 1.0.6a
PHP Code:
refactorsimplify iteration methods
Remove redundant Foreach methods from YYJSONObject and YYJSONArray
- Use inherited ForeachObject and ForeachArray from YYJSON base class 
Updated 1.0.6

PHP Code:
featadd array and object iteration support
Add ForeachObject and ForeachArray methods to YYJSON methodmap
Add Foreach method for array and object iteration
Add documentation and examples for new iteration methods

refactor
improve error handling and type checking
Add type checking in object/array iteration
Improve error messages with detailed type information

docs
update README and API documentation
Update README with better formatting and examples
Add detailed comments for iteration methods
Clarify handle management in API docs
Improve code examples formatting 
ProjectSky is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 00:34.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode