Line 88: |
Line 88: |
| The above JSON table is used in this example. The value which will be selected is P_PV, the one marked by --> in the printout. | | The above JSON table is used in this example. The value which will be selected is P_PV, the one marked by --> in the printout. |
| | | |
− | If the JSON content is stored in local string variable Vjson click ‘Parse JSON’ from the ‘Add Action’ menu, part ‘MacroDroid Specific’ and choose Vjson as ‘Input String Variable’ and Djson as ‘Output Dictionary Variable’ by click on the + symbol. Thereafter Djson can be put to live by a click on ‘JSON Parse’ in the Action window and a further click on ‘Test action’ in the new opened window. | + | If the JSON content is stored in local string variable '''Vjson''' click ‘Parse JSON’ from the ‘Add Action’ menu, part ‘MacroDroid Specific’ and choose '''Vjson''' as ‘Input String Variable’ and by example '''Djson''' as ‘Output Dictionary Variable’ by click on the + symbol. Thereafter '''Djson''' can be put to live by a click on ‘JSON Parse’ in the Action window and a further click on ‘Test action’ in the new opened window. |
| | | |
− | A click on Djson in ‘Local Variables’ at the bottom of the screen shows two entries: ‘Body’ with one entry and ‘Head’ with two entries. A click on ‘Body’ opens a new window with three new entries: ‘Inverters’, ‘Site’ and ‘Version’, each coming with their number of new sub entries. A click on ‘Site’ opens in this case 12 values, each already analysed by content (Boolean, Decimal, Integer and String). Compare it with the printout to get an idea of the JSON structure. | + | A click on '''Djson''' in ‘Local Variables’ at the bottom of the screen shows two entries: '''Body''' with one entry and '''Head''' with two entries. A click on '''Body''' opens a new window with three new entries: '''Inverters''', '''Site''' and '''Version''', each coming with their number of new sub entries. A click on '''Site''' opens in this case 12 values, each already analysed by content (Boolean, Decimal, Integer and String). Compare it with the printout to get an idea of the JSON structure. |
| | | |
− | The next action after ‘JSON Parse’ is ‘Set Variable’ from the ‘Add Action’ menu part ‘MacroDroid Specific’. Give it a name for instance ‘PV’ but never P_PV to avoid conflicts. | + | The next action after ‘JSON Parse’ is ‘Set Variable’ from the ‘Add Action’ menu part ‘MacroDroid Specific’. Give it a name for instance '''PV''' but never P_PV to avoid conflicts. |
− | As P_PV is numeric either Integer (if fractions are of no importance) or Decimal has to be selected. Close the window and select ‘Expression’ in the next window. Click in the blue field right to the ‘Enter value’. In the new window select ‘LocalVar:Djson’ as option. After OK a window ‘Select Dictionary Entry’ opens showing ‘Define Manually’ (for experienced users) and the two main entries [Body] and [Head] of the JSON table. Select Djson[Body]. Proceed to Djson[Body][Data], Djson[Body][Data][Site] and finally select Djson[Body][Data][Site][P_PV]. The ‘Set Variable’ row in the Action window reads after this | + | As P_PV is numeric either Integer (if fractions are of no importance) or Decimal has to be selected. Close the window and select ‘Expression’ in the next window. Click in the blue field right to the ‘Enter value’. In the new window select ‘LocalVar:'''Djson'''’ as option. After OK a window ‘Select Dictionary Entry’ opens showing ‘Define Manually’ (for experienced users) and the two main entries [Body] and [Head] of the JSON table. Select '''Djson'''[Body]. Proceed to '''Djson'''[Body][Data], '''Djson'''[Body][Data][Site] and finally select '''Djson'''[Body][Data][Site][P_PV]. The ‘Set Variable’ row in the Action window reads after this<br> |
| | | |
− | PV:{lv=Djson[Body][Data][Site][P_PV]}. | + | PV:{lv=Djson[Body][Data][Site][P_PV]}.<br> |
| | | |
− | To verify the total action click in the ‘Actions’ window on ‘Set Variable’ and click then on ‘Test Action’. If all went correct the Variable PV in the ‘LocalVariables’ window will show 55, omitting the fractions because PV was declared as integer. Be aware that there might be a problem with the decimal point because in some countries a comma is use instead. | + | To verify the total action click in the ‘Actions’ window on ‘Set Variable’ and click then on ‘Test Action’. If all went correct the Variable '''PV''' in the ‘LocalVariables’ window will show 55, omitting the fractions because '''PV''' was declared as integer. Be aware that there might be a problem with the decimal point because in some countries a comma is use instead. |