Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Determine if a value should be interpreted as True
| ResourceFunction["InterpretedTrueQ"][assoc,key] checks whether the value of key in assoc is interpreted as True. | 
Check a string value:
| In[1]:= | ![ResourceFunction["InterpretedTrueQ"]["true"]](https://www.wolframcloud.com/obj/resourcesystem/images/120/120d5dd4-bf40-4ff2-9c38-ab282d29acea/1ae47061eb3d2dca.png) | 
| Out[1]= |  | 
Check several values:
| In[2]:= | ![AssociationMap[ResourceFunction[
 "InterpretedTrueQ"], {1, 0, "Yes", True, "Grapefruit"}]](https://www.wolframcloud.com/obj/resourcesystem/images/120/120d5dd4-bf40-4ff2-9c38-ab282d29acea/3dc3418aa0b93964.png) | 
| Out[2]= |  | 
Check a value from an Association:
| In[3]:= | ![ResourceFunction["InterpretedTrueQ"][<|"bool" -> "true"|>, "bool"]](https://www.wolframcloud.com/obj/resourcesystem/images/120/120d5dd4-bf40-4ff2-9c38-ab282d29acea/77b3b69ddfe1dfba.png) | 
| Out[3]= |  | 
Use InterpretedTrueQ along with HTTPRequestData within a deployed APIFunction:
| In[4]:= | ![url = First@
  CloudDeploy[
   APIFunction[{}, ResourceFunction["InterpretedTrueQ"][
      HTTPRequestData["Parameters"], "test"] &], Permissions -> "Public"]](https://www.wolframcloud.com/obj/resourcesystem/images/120/120d5dd4-bf40-4ff2-9c38-ab282d29acea/5e5e6d6e43e17591.png) | 
| Out[4]= |  | 
This works like a “Boolean” Interpreter when the parameter is given in the specified part of the request:
| In[5]:= | ![URLExecute@URLBuild[url, {"test" -> "yes"}]](https://www.wolframcloud.com/obj/resourcesystem/images/120/120d5dd4-bf40-4ff2-9c38-ab282d29acea/6e6e0ab0930cfa47.png) | 
| Out[5]= |  | 
| In[6]:= | ![URLExecute@URLBuild[url, {"test" -> "potato"}]](https://www.wolframcloud.com/obj/resourcesystem/images/120/120d5dd4-bf40-4ff2-9c38-ab282d29acea/15e6a24d6fe34b93.png) | 
| Out[6]= |  | 
| In[7]:= | ![URLExecute@URLBuild[url, {}]](https://www.wolframcloud.com/obj/resourcesystem/images/120/120d5dd4-bf40-4ff2-9c38-ab282d29acea/3f78d0b804ef0f3e.png) | 
| Out[7]= |  | 
Check a value in an http header:
| In[8]:= | ![url = First@
  CloudDeploy[
   APIFunction[{}, ResourceFunction["InterpretedTrueQ"][HTTPRequestData["Headers"], "encrypt-response"] &], Permissions -> "Public"]](https://www.wolframcloud.com/obj/resourcesystem/images/120/120d5dd4-bf40-4ff2-9c38-ab282d29acea/1fc5e95aac718120.png) | 
| Out[8]= |  | 
| In[9]:= | ![URLExecute@
 HTTPRequest[url, <|"Headers" -> <|"encrypt-response" -> "1"|>|>]](https://www.wolframcloud.com/obj/resourcesystem/images/120/120d5dd4-bf40-4ff2-9c38-ab282d29acea/614c89b957aea34f.png) | 
| Out[9]= |  | 
| In[10]:= | ![URLExecute@
 HTTPRequest[
  url, <|"Headers" -> <|"encrypt-response" -> "Sorry, I lost my keys"|>|>]](https://www.wolframcloud.com/obj/resourcesystem/images/120/120d5dd4-bf40-4ff2-9c38-ab282d29acea/35fa2a6de362bcd0.png) | 
| Out[10]= |  | 
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License