## Step 1: Define the symbolic variables
Let's define the symbolic variables for the problem:
- $x_1$ represents the amount of money invested in the shoe factory.
- $x_2$ represents the amount of money invested in the hat factory.

## Step 2: Translate the problem into a symbolic representation
The objective is to maximize earnings. The earnings from the shoe factory are 7% of $x_1$, and from the hat factory are 6% of $x_2$. Therefore, the objective function to maximize is $0.07x_1 + 0.06x_2$.

## 3: Define the constraints
The constraints based on the problem description are:
1. The total amount invested is at most $20,000: $x_1 + x_2 \leq 20000$.
2. The amount invested in the shoe factory is at least 4 times the amount invested in the hat factory: $x_1 \geq 4x_2$.
3. The amount invested in the shoe factory can be at most $15,000: $x_1 \leq 15000$.
4. Non-negativity constraints: $x_1 \geq 0$ and $x_2 \geq 0$.

## 4: Symbolic representation in JSON format
```json
{
    'sym_variables': [('x1', 'shoe factory investment'), ('x2', 'hat factory investment')],
    'objective_function': '0.07*x1 + 0.06*x2',
    'constraints': [
        'x1 + x2 <= 20000',
        'x1 >= 4*x2',
        'x1 <= 15000',
        'x1 >= 0',
        'x2 >= 0'
    ]
}
```

## 5: Convert the problem into Gurobi code
```python
import gurobi

def solve_investment_problem():
    # Create a new model
    model = gurobi.Model()

    # Define the variables
    x1 = model.addVar(name="x1", lb=0)  # Investment in shoe factory
    x2 = model.addVar(name="x2", lb=0)  # Investment in hat factory

    # Objective function: maximize 0.07*x1 + 0.06*x2
    model.setObjective(0.07 * x1 + 0.06 * x2, gurobi.GRB.MAXIMIZE)

    # Constraints
    model.addConstr(x1 + x2 <= 20000, name="total_investment")
    model.addConstr(x1 >= 4 * x2, name="shoe_to_hat_ratio")
    model.addConstr(x1 <= 15000, name="shoe_factory_limit")

    # Solve the model
    model.optimize()

    # Print the solution
    if model.status == gurobi.GRB.OPTIMAL:
        print(f"Optimal investment in shoe factory: ${x1.varValue:.2f}")
        print(f"Optimal investment in hat factory: ${x2.varValue:.2f}")
        print(f"Maximum earnings: ${0.07*x1.varValue + 0.06*x2.varValue:.2f}")
    else:
        print("The model is infeasible.")

solve_investment_problem()
```