Generated JSON - showing different results - Fixlet Debugger \ BigFix Action

Hi,

I’m creating some JSON file through ActionScript.

parameter "title_1" = "computer_name"
parameter "param_1" = "{hostname}"
parameter "title_2" = "installed_applications"
parameter "param_2" = "{("[" & it & "]") of concatenation ", " of unique values of ("%22" & value "DisplayName" of it as string & " - " & value "DisplayVersion" of it as string & "%22") of keys whose (exists value "DisplayName" of it AND exists value "DisplayVersion" of it) of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x64 registries; x32 registries)}"

// JSON Syntax : https://en.wikipedia.org/wiki/JSON
// Example : {"first_name":"John","last_name":"Smith","is_alive":true,"age":27,"address":{"street_address":"21 2nd Street","city":"New York","state":"NY","postal_code":"10021-3100"},"phone_numbers":[{"type":"home","number":"212 555-1234"},{"type":"office","number":"646 555-4567"}],"children":["Catherine","Thomas","Trevor"],"spouse":null}

// BigFix
// Title - %22{parameter "title_1"}%22
// One Result - %22{parameter "param_1"}%22
// Array - {parameter "param_1"}
 
parameter "json" = "{{ %22{parameter "title_1"}%22 : %22{parameter "param_1"}%22, %22{parameter "title_2"}%22 : {parameter "param_2"} }"

delete 1.json
createfile until __END__
{parameter "json"}
__END__
move __createfile 1.json

Executing through the Fixlet Debugger - creating the file OK

Executing through the BigFix Action - creating the file with the UTF-8 representation

I know that I will dig into this latter today but I wanted to share the community and getting feedback what i’m missing :slight_smile:

Thank you all

Here the %22 symbols are being used outside of a relevance substitution - so it’s just literally %22

I don’t think you should try to put the whole JSON into a parameter, it’ll just be too difficult to deal with quoting and escapes. You maybe better off building the file a piece at a time with ‘appendfile’ or all at once with ‘createfile’

3 Likes

Looks like it does work if you replace the %22 with quotes. I ran it like that on my lab server and the JSON appears to be formatted ok (it was able to be automatically prettified by a Notepad++ add-on)

1 Like

Thank you all :slight_smile: knew that I was missing something :slight_smile:

parameter "title_1" = "computer_name"
parameter "param_1" = "{hostname}"
parameter "title_2" = "installed_applications"
parameter "param_2" = "{("[" & it & "]") of concatenation ", " of unique values of ("%22" & value "DisplayName" of it as string & " - " & value "DisplayVersion" of it as string & "%22") of keys whose (exists value "DisplayName" of it AND exists value "DisplayVersion" of it) of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (x64 registries; x32 registries)}"

// JSON Syntax : https://en.wikipedia.org/wiki/JSON
// Example : {"first_name":"John","last_name":"Smith","is_alive":true,"age":27,"address":{"street_address":"21 2nd Street","city":"New York","state":"NY","postal_code":"10021-3100"},"phone_numbers":[{"type":"home","number":"212 555-1234"},{"type":"office","number":"646 555-4567"}],"children":["Catherine","Thomas","Trevor"],"spouse":null}

// BigFix
// Title - %22{parameter "title_1"}%22
// One Result - %22{parameter "param_1"}%22
// Array - {parameter "param_1"}
 
parameter "json" = "{{ "{parameter "title_1"}" : "{parameter "param_1"}", "{parameter "title_2"}" : {parameter "param_2"} }"

delete 1.json
createfile until __END__
{parameter "json"}
__END__
move __createfile 1.json

For now this will do :slight_smile:

2 Likes