Jump to content

Recommended Posts

Posted

This works:

Local $json[]
Local $map[]
$map['test'] = 'hello'
Local $array[5] = [1, 2, 3, 4, 5]
$json["data"] = $map
$json["data"]["arr"] = $array
ConsoleWrite(($json["data"]["arr"])[1] & @CRLF)

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted
  On 2/17/2017 at 3:44 PM, water said:
 

This works:

Local $json[]
Local $map[]
$map['test'] = 'hello'
Local $array[5] = [1, 2, 3, 4, 5]
$json["data"] = $map
$json["data"]["arr"] = $array
ConsoleWrite(($json["data"]["arr"])[1] & @CRLF)

 

Expand  

Awesome! But how i can set the value for the array element then?

Local $json[]
Local $map[]
$map['test'] = 'hello'
Local $array[5] = [1, 2, 3, 4, 5]
$json["data"] = $map
$json["data"]["arr"] = $array
ConsoleWrite(($json["data"]["arr"])[1] & @CRLF)
($json["data"]["arr"])[1]=0
ConsoleWrite(($json["data"]["arr"])[1] & @CRLF)

 

Posted

You need to extract the array, modify it and then re-assign it to the map:

Local $json[]
Local $map[]
$map['test'] = 'hello'
Local $array[5] = [1, 2, 3, 4, 5]
$json["data"] = $map
$json["data"]["arr"] = $array
ConsoleWrite(($json["data"]["arr"])[1] & @CRLF)
$aTemp = $json.data.arr
$aTemp[1] = "X"
$json.data.arr = $aTemp
ConsoleWrite(($json["data"]["arr"])[1] & @CRLF)

 

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

:)

My UDFs and Tutorials:

  Reveal hidden contents

 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...