Skip to content

Instantly share code, notes, and snippets.

@edouard
Created May 24, 2014 09:57
Show Gist options
  • Save edouard/b04be2562a03deb120b9 to your computer and use it in GitHub Desktop.
Save edouard/b04be2562a03deb120b9 to your computer and use it in GitHub Desktop.
JSON file "null" to empty string converter
###############################################################################
# JSON file "null" to empty string converter
# For use with WebTranslateIt and Google Chrome extension i18n files
# -WTI will spit out unproofread segments as "null" (without quotes), but
# Chrome needs missing segments to be empty strings
# -Replace "null" with an empty string so that the target files can still be
# properly marked as unproofread in the WTI UI
# Evan Shultz
# Neater Bookmarks
# neaterbookmarks@gmail.com
# 23 May 2014 - v0.1
###############################################################################
# search all reachable paths for files named messages.json
Get-ChildItem -path .\ -include messages.json -recurse |
Foreach-Object {
Write-Host "Procesing $_"
# replace '": null' with empty string write original or modified line
(Get-Content $_) -replace "`": null","`": `"`"" | Set-Content $_
}
Write-Host "`n`nProcessing completed`nPress any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment