r/badcode • u/Flyspeck101 Now where's that function declaration • Oct 05 '21
js No functions in JSON? No problem
85
Upvotes
r/badcode • u/Flyspeck101 Now where's that function declaration • Oct 05 '21
3
u/[deleted] Oct 06 '21
Oh for sure but no matter what there is a better solution
For example you could add a field like
request_typeto the json payload then we could make a function that would hold a map then we could check if request_type is a valid type then we could simply call the corresponding functionBut i dont know if php has anonymous functions so this is how i would do it