ph_texttojson PowerHome formula function
Description
Converts a flattened JSON string back into JSON 
Syntax
ph_texttojson ( as_text, as_segsep, as_valsep, ai_flags )
Argument Description
as_text String. The flattened JSON string or other properly formatted text data
as_segsep String. The character that is used to separate the JSON segments in the formatted text
as_valsep String. The character that is used to separate segments from the value in the formatted text
ai_flags Integer. A flags parameter controlling how the conversion is to be performed. See Usage below
Return value
String. Returns the previously flattened JSON or properly formatted text as a JSON string 
Usage
Use this function to create JSON data from previously flattened JSON such as the output from the ph_flattenjson( ) function or to create JSON from properly formatted text. A sample of properly formatted text appears below: 

Lights.FamilyRoom.status=On
Lights.Kitchen.status=Off
Temperature.FamilyRoom=76.6
Doors.value[0]=5
Doors.value[1]=6
Doors.value[2]=8

The ai_flags parameter currently only supports values of 0 or 1. A value of 0 will NOT try to interpret JSON arrays in the formatted data. A value of 1 will look for JSON arrays in the format of "[indice]" appearing at the end of a JSON segment. In the example formatted text above, you can see a properly formatted JSON array in the "Doors.value" segments.

Examples
The following examples demonstrate typical syntax/usage for this function.
• ph_texttojson("Lights.FamilyRoom.status=On~r~nLights.Kitchen.status=Off~r~nTemperature.FamilyRoom=76.6~r~nDoors.value[0]=5~r~nDoors.value[1]=6~r~nDoors.value[2]=8~r~n",".","=",1) - Returns the following JSON data: {"Lights": {"FamilyRoom": {"status": "On"}, "Kitchen": {"status": "Off"}}, "Temperature": {"FamilyRoom": "76.6"}, "Doors": {"value": [ "5", "6", "8"]}} This example has the ai_flags parameter set to 1 so the Doors.value segment is converted to a JSON array. The next example is the same data with the ai_flags parameter = 0

• ph_texttojson("Lights.FamilyRoom.status=On~r~nLights.Kitchen.status=Off~r~nTemperature.FamilyRoom=76.6~r~nDoors.value[0]=5~r~nDoors.value[1]=6~r~nDoors.value[2]=8~r~n",".","=",0) - Returns the following JSON data: {"Lights": {"FamilyRoom": {"status": "On"}, "Kitchen": {"status": "Off"}}, "Temperature": {"FamilyRoom": "76.6"}, "Doors": {"value[0]": "5", "value[1]": "6", "value[2]": "8"}}