Bakerversity
Module 1: Reclaiming Control of Your Files & ToolsLesson 5 of 8

Lab 1.2: Rescuing Code from Rich Text Corruption

Act as a localization engineer diagnosing and fixing a corrupted JSON string table that was accidentally edited in a rich-text word processor.

Objective

In this lab, you will act as a localization engineer diagnosing and fixing a corrupted JSON string table that was accidentally edited in a rich-text word processor. You will identify curly "smart" quotes, hidden formatting artifacts, and unexpected auto-capitalization, and safely restore the file to valid, plain-text UTF-8 code using Visual Studio Code.


Required Setup & Prerequisites

  • Editor: Visual Studio Code installed.

  • Working Directory: Your active loc_lab_1-1 folder (or loc_lab_1-2).


Step-by-Step Instructions

Step 1: Create the "Corrupted" Rich-Text Export Asset

  1. Open VS Code.

  2. In the Explorer panel, navigate to assets/loc/software/.

  3. Create a new file named ui_ru_corrupted.json.

  4. Copy and paste the following broken code snippet into the file:

json
{ “btn_start”: “Начать игру”, “btn_options”: "Настройки", “welcome_msg”: “Добро пожаловать в “Королевство”!” }
  1. Save the file (Cmd + S / Ctrl + S).


Step 2: Spotting Syntax Errors in VS Code

  1. Look at line 2: Curved quotes (“ and ”) are used around btn_start and Начать игру. JSON syntax strictly requires straight quotes (").

  2. Look at line 4: In addition to curved outer quotes, the inner quotes around Королевство create an unescaped string conflict, breaking the key-value boundary.


Step 3: Perform Global Search & Replace for Smart Quotes

  1. Open Find and Replace:

    • macOS: Cmd + Option + F

    • Windows: Ctrl + H

  2. Find: “ Replace: " Click Replace All.

  3. Find: ” Replace: " Click Replace All.


Step 4: Fix Unescaped Inner Quotes & Sanitize Structure

  1. Insert an escape character (a backslash \) before each inner quote in line 4:

    json
    "welcome_msg": "Добро пожаловать в \"Королевство\"!"
  2. Verify that your final ui_ru_corrupted.json file matches this clean code exactly:

json
{ "btn_start": "Начать игру", "btn_options": "Настройки", "welcome_msg": "Добро пожаловать в \"Королевство\"!" }
  1. Save the file. Observe that all red squiggly syntax warnings in VS Code disappear.


Step 5: Rename to Valid Production File

  1. In the Explorer panel, right-click ui_ru_corrupted.json and select Rename (or press F2).

  2. Rename the file to ui_ru_clean.json.

  3. Confirm that the status bar displays UTF-8 and that the filename ends in .json.

Self-Verification Checklist

Before moving forward, check your cleaned file against these parameters:

  • [ ] All smart/curly quotes (“ ”) have been replaced with standard straight quotes (").

  • [ ] Inner quotes within text values are properly escaped using backslashes (\").

  • [ ] VS Code shows zero red syntax error highlights in the problem panel (Cmd + Shift + M / Ctrl + Shift + M).

  • [ ] File is saved with UTF-8 encoding and named ui_ru_clean.json.


Ready to move on?

Mark this lesson complete when you’re ready.

→ Sign in to track your progress