Closed MAGNAT2645 closed 4 years ago
Hey there! First, thanks for being so active here - it is nice to know that someone is getting good use out of this library.
ShiftInt
/PopInt
) - definitely still a possibility but not as nice as I'd like it to be.arr.parent.SetString("0", "hello")
). I suppose there is no real downside to making them accept ints instead.All of the functionality in the first point I will attempt to include in the next minor release. I would consider points 2 and 3 breaking changes so they will require a new major release.
Thanks again! I will keep this issue updated as I progress.
This library is important for me because i use it for my private Store/Shop system (with inventory and equipment features). I use JSON_Object a lot for Item Attributes (so i can change things like Item name, item description, item max stack etc. and attributes depend on item type and its actions used). For example: i have item that works like letter. There's actually two of this item: blank letter (that you can write and send to other players) and finished letter (its name displays like "Letter from [AUTHOR]" where [AUTHOR] - string value used by letterAuthor attribute)
Recently i started to use this library for players CustomData so every player has its individual data (i can use such data to detect any changes that player made on specific maps etc.) that saves to MySQL DB.
You can also replace some Format
functions with FormatEx
(only if input buffer and output are not same variable) to increase some speed.
EDIT: Also since we have JSON_Array.parent
(idk why but would be good to have uppercase name Parent) we should also have JSON_Object.Child
or JSON_Object.ToArray
property (this would eliminate need to use view_as<JSON_Array>()
)
Thanks for the tip about FormatEx
- I hadn't seen that before, will also be a part of the next update. As for the Child
/ToArray
property, unfortunately that is not possible due to circular reference limitations in SourceMod.
I have replaced Format
with FormatEx
in v2.4.0. I have been thinking a bit about how I want to accomplish the rest of the things you've suggested and am thinking some of it might be out of scope in terms of my intentions for the library. That being said, Sourcemod already provides some of these methods for native arrays, so I am thinking I might add a to/from native array method with which you can perform whatever native functions you want on before converting back to a JSON_Array
. The next release will likely be a major - there are some other things I've been wanting to change that I might look into as well.
Apologies for the delay. I have just released v3.0.0. Pushing values now returns their index as opposed to true or false, as well as many other things.
I haven't yet added some of your other suggestions but I think I may have done one better - you can now export JSON_Array
values to a native array (e.g. int values[]
). This is explained in the README and in the release notes. Once it is exported to a native array, you will be able to use all of Sourcemod's native functions on it (e.g. SortIntegers), which will hopefully provide all of the functionality you require. Once you're finished with it, you can import it back into a JSON_Array
, which is also explained in the README and release notes.
Let me know what you think of this. Thanks!
Sounds cool! Thank you for this update.
Would be good to have new helper methods for
JSON_Array
likeJSON_Array.Swap
,JSON_Array.ShiftUp
and maybeJSON_Array.Sort
(only by integers, floats etc.)EDIT: Also could you add setters for
JSON_Array
so we'll be able to replace values in specific index? EDIT 2: Also i thinkJSON_Array.Push*
should return a new index instead ofbool
(any positive (or null) value instead oftrue
and-1
instead offalse
)