I've taken the liberty of adjusting your code appropriately:
(let* ((json-object-type 'hash-table)
(json (json-read-file "test.json")))
(car (gethash "projects" json)))
The let* is required because otherwise the call to json-read-file will not see the previously bound ...
You're going to have to hash and insert every value no matter what, and unless you're dealing with enormous hash tables, the time spent shouldn't really matter. However, if your tables are large, then you should use the :size parameter to make-hash-table so no reallocations have to occur. When a hash table reaches the threshold, having to reallocate a new ...
append wants sequences and you gave it a cons cell and two hash tables, which is why you get an error. If you want to appends sequences, give it sequences : (append (list (cons ...)) (list hashtable1 hashtable2)) will do what you expected. But now of course it's easier and more efficient to just write (list (cons ...) hashtable1 hashtable2) as suggested in ...
You can use the printed representation for a hash table. From the Emacs documentation:
You can also create a new hash table using the printed representation
for hash tables. The Lisp reader can read this printed representation,
provided each element in the specified hash table has a valid read
syntax (see Printed Representation). For instance, the ...
As npostavs said, it would probably make more sense to use another datastructure, perhaps a B-tree or some other kind of tree, where you wouldn't need to do massive insert / remove operations. Below, however, is a simple example of how one can go about doing this while still using a hash-table:
(let ((example (make-hash-table))
No, you cannot change the order of the keys in a hash table.
As @xuchunyang's comment points out, hash tables do not have an
order in the way you're thinking about them. From the elisp manual node
The correspondences in a hash table are in no particular order.
You may wish to order the keys in some form (say, for the purposes
put is not for hash tables. What you want is puthash.
(puthash KEY VALUE TABLE)
Associate KEY with VALUE in hash table TABLE.
Also you cannot just use puthash on nil, you need to actually create a hash table first with make-hash-table. If you want to use strings as the has keys make sure you pass :test 'equal to make-hash-table.
For all the ...
You question seems too broad. For the part of it that is specific, it seems unclear. Is this really all you are asking for?
(list (cons speedbar-shown-directories (buffer-string))
Please pose as specific a question as you can, as opposed ...
General-purpose weak references would indeed be a useful general-purpose feature for elisp.
It's worth mentioning that in lieu of that functionality, there's a mini convenience library for exactly the strategy you mention (using a hash table with weak values and a single constant as a key) to obtain an effective weak reference: elisp-weak-ref.
If you know the top index, and you know that the indices are consecutive it might be more efficient to loop over those specific indices:
(let ((table #s(hash-table size 65 test eql rehash-size 1.5 rehash-threshold 0.8 data
(1 "/usr/" 2 "/usr/bin" 3 "/usr/include" 4 "/usr/lib" 5 "/usr/libexec"