Open topic with navigation

# lookup

The `lookup` 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

    lookup( pathElements )

## Arguments

Argument | Description
--- | ---
`pathElements` | (json_path_string_or_integer) The path of the value to return. Specify one or more path elements, which might be object attribute names (strings) or array indexes (integers).

## Returns

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

## Example

The following example demonstrates how to obtain a value:

    local myJsonObject = LuaJsonObject:new( { product="IDOL" , version=11 } )
    local myJsonArray = LuaJsonArray:new(0, 1, 2, myJsonObject)
    local myValue = myJsonArray:lookup(3, "product")
    print (myValue:value())
    -- IDOL

The following example demonstrates how modifying a returned value affects the original array:

    local myJsonObject = LuaJsonObject:new()
    myJsonObject:assign("name", LuaJsonArray:new("value1"))

    local myJsonArray = myJsonObject:lookup("name"):array()
    myJsonArray:append("value2")

    print (myJsonObject:string())
    -- {"name":["value1","value2"]}

## See Also

- lookupByPath

© Copyright 2019 Micro Focus or one of its affiliates | Send documentation feedback Close Send documentation feedback To open the configured email client on this computer, open an email window. Otherwise, copy the information below to a web mail client, and send this email to swpdl.idoldocsfeedback@microfocus.com. We appreciate your feedback! Product: Topic Title: Help Topic: Feedback:

_FT_HTML5_bannerTitle.htm