B4J Question [BANano] [SOLVED] BANanoObject.RemoveField(?)

Solution
B4X:
Dim o As BANanoObject
o.Initialize5
Log(o)
Log(o.GetField("someProp"))
    
' check if someProp exists
If o.GetField("someProp") = BANano.UNDEFINED Then
     o.SetField("someProp", "test")
     Log(o)
     Log(o.GetField("someProp"))
End If
    
' remove someProp
o.Delete("someProp")
Log(o)
Log(o.GetField("someProp"))

Result:
B4X:
{}
undefined
{someProp: 'test'}
test
{}
undefined

Alwaysbusy

alwaysbusy

Expert
Licensed User
Longtime User
B4X:
Dim o As BANanoObject
o.Initialize5
Log(o)
Log(o.GetField("someProp"))
    
' check if someProp exists
If o.GetField("someProp") = BANano.UNDEFINED Then
     o.SetField("someProp", "test")
     Log(o)
     Log(o.GetField("someProp"))
End If
    
' remove someProp
o.Delete("someProp")
Log(o)
Log(o.GetField("someProp"))

Result:
B4X:
{}
undefined
{someProp: 'test'}
test
{}
undefined

Alwaysbusy
 
Upvote 2
Solution
Cookies are required to use this site. You must accept them to continue using the site. Learn more…