Description
Checks if the path exists.
Applies to
Syntax
objectname.ContainsPath ( ItemPath )
| 
                                            
                               Argument  | 
                           
                                            
                               Description  | 
                        
|---|---|
| 
                                            
                               objectname  | 
                           
                                            
                               The name of the JSONParser object whose path you want to check.  | 
                        
| 
                                            
                               ItemPath  | 
                           
                                            
                               A string whose value is the path of the item of JsonArrayItem type. If there is a multi-dimensional array, use the number to indicate the order of the array elements. If a key name contains "/", use the escape character "~~/" to replace "/".  | 
                        
Return value
Boolean. Returns true if the item path exists and false if an error occurs. If any argument's value is null, the method returns null.
Example 1
This example loads a JSON string into a JSONParser object and checks if the specified path exists:
String         ls_Return, ls_Path
Boolean        lb_Contains
JSONItemType   ljit_Dept
JsonParser     ljp_ContainsPath
ljp_ContainsPath = Create JsonParser
// Loads JSON string to JSONParser object
ls_Return = ljp_ContainsPath.LoadString ( '{"Boolean":false, "Name":"A&DName", "object":{"1":"1"}, "dept":[{"dept_id":100, "dept_name":"R & D8", "dept_head_id":105}, {"dept_id":200, "dept_name":"Sales", "dept_head_id":129}]}'  )
If Trim(ls_Return)<>"" Then 
  // Prints the error message
  Return
End If
// Checks if JSONParser parent node contains a Boolean path
// This script returns TRUE
ls_Path = "/Boolean"
lb_Contains = ljp_ContainsPath.ContainsPath( ls_Path )
ls_Path = "/dept"
lb_Contains = ljp_ContainsPath.ContainsPath( ls_Path )
If lb_Contains Then
  ljit_Dept = ljp_ContainsPath.getitemtype( ls_Path )
  If ljit_Dept = JsonArrayItem! Then    
    // Checks if the first element contains a dept_name path
    // This script returns TRUE
    ls_Path = "/dept/1/dept_name"
    lb_Contains = ljp_ContainsPath.ContainsPath( ls_Path )
    
    // Checks if the first element contains a Boolean path
    // This script returns FALSE  
    ls_Path = "/dept/1/Boolean"
    lb_Contains = ljp_ContainsPath.ContainsPath( ls_Path )                     
  Else
    // Prints error message: the dept path is JsonArrayItem
  End If             
Else
   // Prints the error message
End If
See also


