Problems

setState Batch Reducer

MediumProps & State

State starts as a JSON object. Each following line is a partial update (JSON) that shallow-merges into state, like setState. Print the final state as JSON with keys sorted.

Input: line 1 — initial state; following lines — patches. Output: final state JSON, keys sorted.

Your program reads from stdin and prints to stdout.

Example 1

Input: {"count":0,"name":"x"} {"count":1} {"count":2,"flag":true}

Output: {"count":2,"flag":true,"name":"x"}

Hints

ReactStatesetState
setState Batch Reducer | CodeForge AI