lookupByPath

The lookupByPath method returns the value at the specified path in the JSON array.

NOTE:

This method does not make a copy of the value, so modifying the returned value affects the original array.

Syntax

lookupByPath( path )

Arguments

Argument Description
path (string) The path of the value to return. Construct the path from array indexes and object attribute names, and use a slash (/) as the separator. If an object attribute name includes a slash, then escape the slash with a backslash, for example "one\\/two". Notice that you must also escape a backslash with another backslash.

Returns

(LuaJsonValue) Returns the value that exists at the specified path, or nil if the specified path does not exist.

Example

local myJsonObject = LuaJsonObject:new( { product="IDOL" , version=11 } )
local myJsonArray = LuaJsonArray:new("zero",1,2,myJsonObject)

local myValue = myJsonArray:lookupByPath("3/product")
print (myValue:value())
-- IDOL

See Also


_HP_HTML5_bannerTitle.htm