I am creating a JSON file using powershell and using the JSON file as a chef-runtime attribute.
Code to create JSON file (in powershell)
New-Item $ATTRIBUTESFILE -ItemType file
$jsonInput = @{param1=@{subparam=$attribute}}
$ATTRIBUTE = $jsonInput | ConvertTo-Json
$ATTRIBUTE | Out-File $ATTRIBUTESFILE
Code to call the chef-client
chef-client -o 'recipe[cookbook]' -j $ATTRIBUTESFILE
Error message
c:/chef/embedded/lib/ruby/gems/1.9.1/gems/yajl-ruby-1.1.0-x86-mingw32/lib/yajl.rb:36:in `parse': lexical error:
invalid char in json text. (Yajl::ParseError)
ÿ_{ (right here) ------^
from c:/chef/embedded/lib/ruby/gems/1.9.1/gems/yajl-ruby-1.1.0-x86-mingw32/lib/yajl.rb:36:in `parse'
from c:/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-11.6.0/lib/chef/json_compat.rb:56:in `from_json'
When I create the same file manually, it gives no lexical error. Any help on this would be appreciated.