southclaws / pawn-json Goto Github PK
View Code? Open in Web Editor NEWJSON for Pawn.
License: MIT License
JSON for Pawn.
License: MIT License
Hello! Can you give me example for function JSON_ArrayAppend?
i need to make this json: {"items": [{"index": 0, "name": "Nissan GT-R"}, {"index": 1, "name": "Cadillac Escalade"}]}
buy i dont know how i can add objects to array with cycle
Hello! Why is there a JSON_ArrayRemoveIndex but not a JSON_ArrayAppendIndex? How to update information by index in an array?
I would like to see the ability to parse from a file by pointing to its URL.
Example:
new Node:node;
JSON_ParseHTTPFile("http://my-site.com/cdn/config.json", node);
when installing this package u get the next error
WARN: failed to ensure package github.com/Southclaws/pawn-json: failed to ensure asset: failed to get plugin Southclaws/pawn-json from net: resource matcher 'pawn-json-windows.zip' does not match any release assets from '[ json.dll json.so]
Hello. JSON_Stringify crash server. I am see code:
#[native(name = "JSON_Stringify")]
pub fn json_stringify(
&mut self,
_: &Amx,
node: i32,
output: UnsizedBuffer,
length: usize,
) -> AmxResult<i32> {
let v: &serde_json::Value = match self.json_nodes.get(node) {
Some(v) => v,
None => return Ok(1),
};
let s = match serde_json::to_string(&v) {
Ok(v) => v,
Err(e) => {
error!("{}", e);
return Ok(1);
}
};
let mut dest = output.into_sized_buffer(length);
let _ = samp::cell::string::put_in_buffer(&mut dest, &s);
Ok(0)
}
there is no check for the size of the buffer, and if it is not enough, then there will be overflows and the server will crash
Problem with pawn-json version 1.1.0:
I have a PC with Windows 10 Single Language of 64 bits, I installed pawn-json by sampctl.
When i execute the server, the plugin don't load:
[20:12:41] Loading plugin: json
[20:12:41] Failed.
I tested the plugin by placing it in a different order in server.cfg but I also got the same result in W10.
Since no message appears, I don't know if I should install something additional on my machine, or if it is a problem with the plugin itself.
Also i tried the plugin in Debian 8: don't work.
Also i tried the plugin en Ubuntu 20.04: work correctly.
Thanks.
I implemented this plugin and experience random sampgdk warnings upon doing various actions. Here's a snippet from my server log.
[06/15/2020 18:23:23] [join] TommyB has joined the server (1:127.0.0.1)
[06/15/2020 18:23:23] [sampgdk:warning] Native function not found: IsPlayerNPC
[06/15/2020 18:23:23] [sampgdk:warning] Native function not found: IsPlayerInAnyVehicle
[06/15/2020 18:23:29] [Login] TommyB
[06/15/2020 18:24:30] [sampgdk:warning] Native function not found: MovePlayerObject
Please Help.
Can anyone update the release to the current master? Thank you very much in advance. ❤️
P.S. you should also close other problems if they are still solved or answered :3
Hi, crash server with JSON_Stringify. Code:
// global var
new Node: g_node_leaders_list_json = Node:-1;
// some SA-MP callback (for example OnPlayerConnect)
static buf[82_000];
if (JSON_Stringify(g_node_leaders_list_json, buf) == 0)
{
// useful logic
}
buf[0] = '\0';
// in main/OnGameModeInit
g_node_leaders_list_json = JSON_Object();
JSON_SetArray(g_node_leaders_list_json, "leaders", JSON_Array());
JSON_ArrayAppend(g_node_leaders_list_json, "leaders", JSON_Object(
"fraction_id", JSON_Int(f_info[i][f_id]),
"fraction_name", JSON_String(f_info[i][f_name]),
"fraction_leader_name", JSON_String(f_info[i][f_leader_name])
)
);
Stracktrace:
Thread 1 "samp03svr" received signal SIGSEGV, Segmentation fault.
0xf596fe12 in hashbrown::raw::sse2::Group::load () at /cargo/registry/src/github.com-1285ae84e5963aae/hashbrown-0.12.3/src/raw/sse2.rs:50
50 /cargo/registry/src/github.com-1285ae84e5963aae/hashbrown-0.12.3/src/raw/sse2.rs: No such file or directory.
(gdb) bt 10
#0 0xf596fe12 in hashbrown::raw::sse2::Group::load ()
at /cargo/registry/src/github.com-1285ae84e5963aae/hashbrown-0.12.3/src/raw/sse2.rs:50
#1 hashbrown::raw::RawTableInner<alloc::alloc::Global>::find_inner<alloc::alloc::Global> (self=0x81ffbec,
hash=3136313669715300515, eq=...)
at /cargo/registry/src/github.com-1285ae84e5963aae/hashbrown-0.12.3/src/raw/mod.rs:1174
#2 0xf5969304 in hashbrown::raw::RawTable<(samp::amx::AmxIdent, samp_sdk::amx::Amx), alloc::alloc::Global>::find<(samp::amx::AmxIdent, samp_sdk::amx::Amx), alloc::alloc::Global, hashbrown::map::equivalent_key::{closure_env#0}<samp::amx::AmxIdent, samp::amx::AmxIdent, samp_sdk::amx::Amx>> (self=0x81ffbec, hash=3136313669715300515, eq=...)
at /cargo/registry/src/github.com-1285ae84e5963aae/hashbrown-0.12.3/src/raw/mod.rs:816
#3 0xf5969248 in hashbrown::raw::RawTable<(samp::amx::AmxIdent, samp_sdk::amx::Amx), alloc::alloc::Global>::get<(samp::amx::AmxIdent, samp_sdk::amx::Amx), alloc::alloc::Global, hashbrown::map::equivalent_key::{closure_env#0}<samp::amx::AmxIdent, samp::amx::AmxIdent, samp_sdk::amx::Amx>> (self=0x81ffbec, hash=3136313669715300515, eq=...)
at /cargo/registry/src/github.com-1285ae84e5963aae/hashbrown-0.12.3/src/raw/mod.rs:831
#4 0xf596c474 in hashbrown::map::HashMap<samp::amx::AmxIdent, samp_sdk::amx::Amx, std::collections::hash::map::RandomState, alloc::alloc::Global>::get_inner<samp::amx::AmxIdent, samp_sdk::amx::Amx, std::collections::hash::map::RandomState, alloc::alloc::Global, samp::amx::AmxIdent> (self=0x81ffbdc, k=0xffffb4c8)
at /cargo/registry/src/github.com-1285ae84e5963aae/hashbrown-0.12.3/src/map.rs:1271
#5 0xf596c084 in hashbrown::map::HashMap<samp::amx::AmxIdent, samp_sdk::amx::Amx, std::collections::hash::map::RandomState, alloc::alloc::Global>::get<samp::amx::AmxIdent, samp_sdk::amx::Amx, std::collections::hash::map::RandomState, alloc::alloc::Global, samp::amx::AmxIdent> (self=0x81ffbdc, k=0xffffb4c8)
at /cargo/registry/src/github.com-1285ae84e5963aae/hashbrown-0.12.3/src/map.rs:1223
#6 0xf596cd64 in std::collections::hash::map::HashMap<samp::amx::AmxIdent, samp_sdk::amx::Amx, std::collections::hash::map::RandomState>::get<samp::amx::AmxIdent, samp_sdk::amx::Amx, std::collections::hash::map::RandomState, samp::amx::AmxIdent> (self=0x81ffbdc, k=0xffffb4c8)
at /rustc/897e37553bba8b42751c67658967889d11ecd120/library/std/src/collections/hash/map.rs:881
#7 0xf59083e1 in samp::amx::get (ident=...)
at /home/continue/.cargo/git/checkouts/samp-rs-4c9888f6d3249d70/2e91927/samp/src/amx.rs:48
#8 0xf58e62af in pawn_json::plugin::Plugin::__samp_native_json_stringify (amx=0x836fdd0, args=0xf4dfe1e8)
crashdetect log:
[01:40:20] Server crashed while executing npc_record.amx
[01:40:20] AMX backtrace:
[01:40:20] #0 native JSON_Stringify () in libpawn_json.so
[01:40:20] #1 0129d97c in public jtc_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #2 00b8c3f0 in public a_fac_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #3 00b4d614 in public taxi_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #4 00b4029c in public road_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #5 00a38734 in public fire_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #6 009c66c0 in public g_cth_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #7 009ab498 in public g_wh_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #8 00999ec0 in public mayor_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #9 00997324 in public depart_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #10 009761ec in public ems_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #11 00964d0c in public army_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #12 00944e94 in public fbi_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #13 00939528 in public tune_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #14 00930a14 in public tc_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #15 0091b898 in public taxic_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #16 008f6128 in public f_cont_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #17 00889ee0 in public fam_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #18 00863730 in public d_sch_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #19 0085bc64 in public drv_school_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #20 00796bb4 in public tuning_exterior_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #21 00741ad0 in public auto_market_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #22 00485e30 in public fbi_int_flr1_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #23 00435e3c in public fire_st_sf_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #24 003ed118 in public road_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #25 00368e8c in public farm_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #26 00293050 in public samwill_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #27 002882d0 in public ballas_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #28 001f0da0 in public fishing_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #29 001cad18 in public furnit_fact_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #30 001bd9e8 in public taxi_exterior_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #31 0017132c in public transp_comp_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #32 00128760 in public mine_exterior_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #33 000eeda0 in public bus_statn_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #34 000e2f50 in public train_statn_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #35 000d46dc in public vagos_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #36 000d46b0 in public aztecas_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #37 000d4684 in public rifa_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #38 000d4658 in public phone_tow_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #39 000a2f78 in public job_builder_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #40 0006f914 in public electric_ext_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #41 000651cc in public electric_int_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #42 00029808 in public reg_auth_bg_int_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #43 0001dd9c in public _PrimeRP_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #44 0001dba4 in public PRIME_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #45 0000a7f0 in public Iter_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #46 00008dc4 in public SSCANF_OnPlayerConnect (0) in npc_record.amx
[01:40:20] #47 00000dbc in public OnPlayerConnect (0) in npc_record.amx
[01:40:20] Native backtrace:
[01:40:20] #0 f6377f7f in _Z13GetStackTraceRSt6vectorI10StackFrameSaIS0_EEPv () in plugins/crashdetect.so
[01:40:20] #1 f637081d in _ZN11CrashDetect20PrintNativeBacktraceERSoRKN2os7ContextE () in plugins/crashdetect.so
[01:40:20] #2 f6370e48 in _ZN11CrashDetect20PrintNativeBacktraceERKN2os7ContextE () in plugins/crashdetect.so
[01:40:20] #3 f63725dc in _ZN11CrashDetect7OnCrashERKN2os7ContextE () in plugins/crashdetect.so
[01:40:20] #4 f637779f in ?? () in plugins/crashdetect.so
[01:40:20] #5 f7efa580 in __kernel_rt_sigreturn () in linux-gate.so.1
[01:40:20] #6 f77e21d2 in ?? () in plugins/libpawn_json.so
[01:40:20] #7 f77db794 in ?? () in plugins/libpawn_json.so
[01:40:20] #8 f77db6d8 in ?? () in plugins/libpawn_json.so
[01:40:20] #9 f77de254 in ?? () in plugins/libpawn_json.so
[01:40:20] #10 f77dde64 in ?? () in plugins/libpawn_json.so
[01:40:20] #11 f77de974 in ?? () in plugins/libpawn_json.so
[01:40:20] #12 f778eb81 in ?? () in plugins/libpawn_json.so
[01:40:20] #13 f777bb1f in ?? () in plugins/libpawn_json.so
[01:40:20] #14 080950e4 in ?? () in ./samp03svr
[01:40:20] #15 f637046f in _ZN11CrashDetect15ProcessCallbackEiPiS0_ () in plugins/crashdetect.so
[01:40:20] #16 f6375feb in ?? () in plugins/crashdetect.so
[01:40:20] Registers:
[01:40:20] EAX: ffdc0a08 EBX: f7964e0c ECX: ffdc0a08 EDX: ffffffff
[01:40:20] ESI: 00000045 EDI: 00000000 EBP: ffdc0dc0 ESP: ffdc0908
[01:40:20] EIP: f77e21d2 EFLAGS: 00010282
[01:40:20] Stack:
[01:40:20] ESP+00000000: ffdc0a08 0963ee92 f08430c0 19479c67
[01:40:20] ESP+00000020: fe4fc621 be426119 c621be42 6119fe4f
[01:40:20] ESP+00000040: 5b7d7d33 f7964e0c b77d3d52 8abd5b1a
[01:40:20] ESP+00000060: fd9a63f4 6e09a05a 00000002 00000000
[01:40:20] ESP+00000080: b301adf3 ece9f8af c61ffb76 6070b957
[01:40:20] ESP+000000a0: ffdc0ab0 f795d0ac b77d3d52 8abd5b1a
[01:40:20] ESP+000000c0: 5b7bd9b8 0946f07c b77d3d52 8abd5b1a
[01:40:20] ESP+000000e0: 0963ee90 0963ee90 00000002 0963ee90
[01:40:20] ESP+00000100: ffffff5b ffffffff ffffffff ffffffff
[01:40:20] ESP+00000120: ffdc0a68 04000000 09608fb0 f780b589
[01:40:20] ESP+00000140: 09608fb0 04000000 3d542a11 4a2a7488
[01:40:20] ESP+00000160: 8abd5b1a ffdc0ab0 f7964e0c f77db794
[01:40:20] ESP+00000180: f795d0ac ffdc0ac8 f7964e0c f7964e0c
[01:40:20] ESP+000001a0: ffdc0ac8 ffdc0ac8 ffdc0b04 0946f07c
[01:40:20] ESP+000001c0: 6850b881 aa90a56b d52caab6 4afe2969
[01:40:20] ESP+000001e0: 8abd5b1a ffdc0bf8 f7964e0c f77db6d8
[01:40:20] ESP+00000200: 094a3710 08163c35 f7964e0c f77de294
[01:40:20] ESP+00000220: 8abd5b1a ffdc0bf8 f7964e0c f77de254
[01:40:20] ESP+00000240: 0946f07c ffdc0bf8 8abd5b1a b77d3d52
[01:40:20] ESP+00000260: 0946f07c 0946f07c b77d3d52 8abd5b1a
[01:40:20] ESP+00000280: 0946f06c ffdc0bf8 00000000 f5be1eb4
[01:40:20] ESP+000002a0: 0946f06c ffdc0bf8 00000018 ffdc0c68
[01:40:20] ESP+000002c0: 0946f06c ffdc0bf8 ffdc0c68 0bdebe60
[01:40:20] ESP+000002e0: 0946f060 0946f060 f7964e0c f777bb1f
[01:40:20] ESP+00000300: 0948a1dc 00000000 00000000 00000005
[01:40:20] ESP+00000320: 00000002 09608fb0 ffdc0d90 080d807c
[01:40:20] ESP+00000340: 00000030 00000800 00000000 ffdc0c59
[01:40:20] ESP+00000360: f500389c 09608fb0 0948a070 ffdc0c79
[01:40:20] ESP+00000380: f4f62cdc 00000001 f5c0235f f5f504a0
[01:40:20] ESP+000003a0: ffdc0ce8 0948a248 00000000 00000001
[01:40:20] ESP+000003c0: 3f800000 00002928 f7f2fff4 f5bfbf34
[01:40:20] ESP+000003e0: f5be79c4 f5cbbc60 f79e5bf9 f7968f8c
[01:40:20] Loaded modules:
[01:40:20] 00000000 - 00187dc3 samp03svr
[01:40:20] f7efa000 - f7efb3a0 linux-gate.so.1
[01:40:20] f7ee3000 - f7ee3aa8 /lib/i386-linux-gnu/libdl.so.2
[01:40:20] f7ede000 - f7edf148 /lib/i386-linux-gnu/libpthread.so.0
[01:40:20] f7cbe000 - f7eea984 /lib/i386-linux-gnu/libstdc++.so.6
[01:40:20] f7bb9000 - f7cbd32c /lib/i386-linux-gnu/libm.so.6
[01:40:20] f7b92000 - f7bb5e60 /lib/i386-linux-gnu/libgcc_s.so.1
[01:40:20] f796a000 - f7b9967d /lib/i386-linux-gnu/libc.so.6
[01:40:20] f7efc000 - f7f306bd /lib/ld-linux.so.2
[01:40:20] f776d000 - f7975668 plugins/libpawn_json.so
[01:40:20] f7768000 - f7769058 /lib/i386-linux-gnu/librt.so.1
[01:40:20] f73d7000 - f776ceb2 plugins/mysql.so
[01:40:20] f73b3000 - f73d6d32 /home/samp-servers/servers/primerp_saibot/plugins/../log-core.so
[01:40:20] f604e000 - f620a078 plugins/pawncmd.so
[01:40:20] f63a1000 - f63b01d4 plugins/sscanf.so
[01:40:20] f7eee000 - f7ef17a0 plugins/TOTP.so
[01:40:20] f6358000 - f63a03d4 plugins/crashdetect.so
[01:40:20] f5f7b000 - f604fb05 plugins/streamer.so
[01:40:20] f6318000 - f63573b9 plugins/launcher.so
[01:40:20] f5bcb000 - f5f83b78 plugins/clientside.so
[01:40:20] f59fc000 - f5bd6690 plugins/pawnraknet.so
[01:40:20] f6314000 - f6315f70 plugins/nativechecker.so
OS: Debian GNU/Linux bookworm/sid x86_64, Kernel: 5.17.0-1-amd64
I would really like to store json in mysql, but here's the problem to get a value from Mysql, we need to know the length of the string ( cache_get_value_name), it is possible to somehow bypass this system or make some kind of crutch. p.s: I do not know the length that will come to me, because this is a dynamic list
I'm trying to read a .json file but I'm not getting success.
Can you help me?
I have a file called test.json
{
"name": "Testing",
"id": 13,
"settings": {
"speed": 70,
"limit": 150
},
}
new Node:node;
new ret;
ret = JsonParse("test.json", node);
JsonParse parses a file from scriptfiles?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.