<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged parsing</title>
<link>https://coderlegion.com/tag/parsing</link>
<description>Powered by Question2Answer</description>
<item>
<title>Json.decoder.jsondecodeerror: expecting value: line 1 column 1</title>
<link>https://coderlegion.com/24971/json-decoder-jsondecodeerror-expecting-value-line-1-column-1</link>
<description>&lt;h2&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;/h2&gt;&lt;p&gt;How do I do  this &quot;json.decoder.jsondecodeerror: expecting value: line 1 column 1 (char 0)&quot;?&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;Solution:&lt;br&gt;
To summarize the conversation in the comments:&lt;/p&gt;
&lt;p&gt;There is no need to use simplejson library, the same library is included with Python as the json module.&lt;/p&gt;
&lt;p&gt;There is no need to decode a response from UTF8 to unicode, the simplejson / json .loads() method can handle UTF8 encoded data natively.&lt;/p&gt;
&lt;p&gt;pycurl has a very archaic API. Unless you have a specific requirement for using it, there are better choices.&lt;/p&gt;
&lt;p&gt;requests offers the most friendly API, including JSON support. If you can, replace your call with:&lt;/p&gt;
&lt;p&gt;import requests&lt;/p&gt;
&lt;p&gt;return requests.get(url).json()&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://kodlogs.net/?qa=blob&amp;amp;qa_blobid=15533609407522969688&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h3&gt;Solution &lt;/h3&gt;
&lt;p&gt;Be sure to remember to invoke json.loads() on the contents of the file, as opposed to the file path of that JSON:&lt;/p&gt;
&lt;p&gt;json_file_path = &quot;/path/to/example.json&quot;&lt;/p&gt;
&lt;p&gt;with open(json_file_path, 'r') as j:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; contents = json.loads(j.read())
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I think a lot of people are guilty of doing this every once in a while (myself included):&lt;/p&gt;
&lt;p&gt;contents = json.loads(json_file_path)&lt;/p&gt;
&lt;p&gt;As such, if parsing fails despite having a data-body that looks JSON like at first glance, try replacing the quotes of the data-body:&lt;/p&gt;
&lt;p&gt;import sys, json&lt;br&gt;
struct = {}&lt;br&gt;
try:&lt;br&gt;
  try: #try parsing to dict&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;dataform = str(response_json).strip(&quot;'&amp;lt;&amp;gt;() &quot;).replace('\'', '\&quot;')
struct = json.loads(dataform)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;  except:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;print repr(resonse_json)
print sys.exc_info()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A lot of times, this will be because the string you're trying to parse is blank:&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; import json&lt;br&gt;
&amp;gt;&amp;gt;&amp;gt; x = json.loads(&quot;&quot;)&lt;br&gt;
Traceback (most recent call last):&lt;br&gt;
  File &quot;&quot;, line 1, in &lt;br&gt;
  File &quot;/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/&lt;strong&gt;init&lt;/strong&gt;.py&quot;, line 348, in loads&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;return _default_decoder.decode(s)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;  File &quot;/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py&quot;, line 337, in decode&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;obj, end = self.raw_decode(s, idx=_w(s, 0).end())
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;  File &quot;/usr/local/Cellar/python/3.7.3/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py&quot;, line 355, in raw_decode&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;raise JSONDecodeError(&quot;Expecting value&quot;, s, err.value) from None
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)&lt;br&gt;
You can remedy by checking whether json_string is empty beforehand:&lt;/p&gt;
&lt;p&gt;import json&lt;/p&gt;
&lt;p&gt;if json_string:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;x = json.loads(json_string)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;else:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;# Your code/logic here 
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/24971/json-decoder-jsondecodeerror-expecting-value-line-1-column-1</guid>
<pubDate>Thu, 20 Aug 2026 07:04:57 +0000</pubDate>
</item>
<item>
<title># Dynamically Generated Languages Solve the Same Class of Problems as MCP Servers — and Do It Better</title>
<link>https://coderlegion.com/9963/dynamically-generated-languages-solve-the-same-class-problems-mcp-servers-and-it-better</link>
<description>&lt;p&gt;After battle-testing these ideas in practice, here is my conclusion:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Centralized interaction and intent architectures are inevitable.&lt;/strong&gt;&lt;br&gt;
The only real question is whether we build them as &lt;em&gt;formal systems&lt;/em&gt; or &lt;em&gt;probabilistic agents&lt;/em&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;from-clicking-and-scrolling-to-invoking-capabilities&quot;&gt;From Clicking and Scrolling to Invoking Capabilities&lt;/h3&gt;
&lt;p&gt;User interaction is moving away from clicking and scrolling and toward &lt;strong&gt;invoking capabilities directly&lt;/strong&gt;, most notably via voice.&lt;/p&gt;
&lt;p&gt;This shift is powerful:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;If you can name a capability, you can invoke it  &lt;/li&gt;
&lt;li&gt;Interaction becomes direct  &lt;/li&gt;
&lt;li&gt;UX complexity drops dramatically  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;From a UX-complexity standpoint, this is a clear win.&lt;/p&gt;
&lt;p&gt;However, this change forces a &lt;strong&gt;fundamental architectural shift&lt;/strong&gt; compared to traditional frontend setups.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;react-and-the-problem-of-distributed-capabilities&quot;&gt;React and the Problem of Distributed Capabilities&lt;/h3&gt;
&lt;p&gt;Consider a typical React application.&lt;/p&gt;
&lt;p&gt;In React:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Capabilities are exposed through &lt;strong&gt;components&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Components expose behavior via &lt;strong&gt;props and callbacks&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Capabilities are therefore &lt;strong&gt;distributed by construction&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There is no centralized place where “what the system can do” exists.&lt;/p&gt;
&lt;p&gt;Trying to centralize this in React quickly reveals deep friction:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Hooks produce &lt;strong&gt;unstable references&lt;/strong&gt; across renders  &lt;/li&gt;
&lt;li&gt;Central registries must constantly re-register handlers  &lt;/li&gt;
&lt;li&gt;Context-based solutions become brittle and stateful  &lt;/li&gt;
&lt;li&gt;Unsubscribing DOM listeners requires the &lt;strong&gt;exact same function reference&lt;/strong&gt;  &lt;/li&gt;
&lt;li&gt;That reference is often no longer available or stable  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Yes, you &lt;em&gt;can&lt;/em&gt; build a capability registry on top of React.&lt;/p&gt;
&lt;p&gt;But it is:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Clunky  &lt;/li&gt;
&lt;li&gt;Hard to reason about  &lt;/li&gt;
&lt;li&gt;Tightly coupled to rendering lifecycle  &lt;/li&gt;
&lt;li&gt;Architecturally inverted  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;All of this is a strong signal:&lt;br&gt;
&lt;strong&gt;centralized capability invocation does not belong inside the UI layer.&lt;/strong&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;centralization-is-not-optional&quot;&gt;Centralization Is Not Optional&lt;/h3&gt;
&lt;p&gt;Now compare this with a system like the Visual Studio Code command palette.&lt;/p&gt;
&lt;p&gt;VS Code exposes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;A centralized&lt;/li&gt;
&lt;li&gt;Runtime-configurable&lt;/li&gt;
&lt;li&gt;Discoverable&lt;/li&gt;
&lt;li&gt;Uniform command surface&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Once a command is registered:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It does not matter where it lives  &lt;/li&gt;
&lt;li&gt;It does not matter which UI triggered it  &lt;/li&gt;
&lt;li&gt;It can be invoked uniformly  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is not an accident.&lt;br&gt;
It is a &lt;strong&gt;capability-first architecture&lt;/strong&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-natural-conclusion-a-decoupled-capability-layer&quot;&gt;The Natural Conclusion: A Decoupled Capability Layer&lt;/h3&gt;
&lt;p&gt;What naturally follows is a module that:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Is decoupled from the frontend  &lt;/li&gt;
&lt;li&gt;Has no dependency on UI frameworks  &lt;/li&gt;
&lt;li&gt;Accepts voice or textual input  &lt;/li&gt;
&lt;li&gt;Emits discrete, authorized commands  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;At first glance, this smells like parsing.&lt;/p&gt;
&lt;p&gt;And that is exactly what it is — with one important caveat.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;this-is-parsing-not-ai&quot;&gt;This Is Parsing — Not AI&lt;/h3&gt;
&lt;p&gt;Traditional parsing assumes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Full input available upfront  &lt;/li&gt;
&lt;li&gt;A lexing phase  &lt;/li&gt;
&lt;li&gt;A parsing phase  &lt;/li&gt;
&lt;li&gt;A final AST  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;User interaction does not work this way.&lt;/p&gt;
&lt;p&gt;For voice and interactive input we need:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Incremental parsing  &lt;/li&gt;
&lt;li&gt;Partial feedback  &lt;/li&gt;
&lt;li&gt;Real-time guidance  &lt;/li&gt;
&lt;li&gt;Asynchronous evaluation  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is not AI.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;This is asynchronous parsing.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;That distinction matters.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;mcp-servers-and-the-core-problem&quot;&gt;MCP Servers and the Core Problem&lt;/h3&gt;
&lt;p&gt;MCP servers attempt to solve a similar problem:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Centralized capability invocation  &lt;/li&gt;
&lt;li&gt;Access via natural language  &lt;/li&gt;
&lt;li&gt;Location-agnostic execution  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;In practice:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Once a capability is integrated, its origin no longer matters  &lt;/li&gt;
&lt;li&gt;If you can name it, you can invoke it  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On the surface, this sounds ideal.&lt;/p&gt;
&lt;p&gt;It is not.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;why-informal-invocation-is-dangerous&quot;&gt;Why Informal Invocation Is Dangerous&lt;/h3&gt;
&lt;p&gt;MCP-style systems rely on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;NLP → mapping informal language to formal side effects  &lt;/li&gt;
&lt;li&gt;Agents → which can and do hallucinate  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This creates a fundamental mismatch:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Informal input&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Formal consequences&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The moment real side effects exist, you must introduce:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Authorization  &lt;/li&gt;
&lt;li&gt;Capability scoping  &lt;/li&gt;
&lt;li&gt;Denial rules  &lt;/li&gt;
&lt;li&gt;Auditability  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;At that point, you are already rebuilding a &lt;strong&gt;formal system&lt;/strong&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;languages-are-formal-systems&quot;&gt;Languages Are Formal Systems&lt;/h3&gt;
&lt;p&gt;Languages:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Are minimal  &lt;/li&gt;
&lt;li&gt;Are precise  &lt;/li&gt;
&lt;li&gt;Can be syntactically close to natural language  &lt;/li&gt;
&lt;li&gt;Support deterministic navigation  &lt;/li&gt;
&lt;li&gt;Enable runtime introspection (autocomplete, discovery)  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Most importantly:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Languages allow relational identification.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Objects are identified not by name alone, but by their position in a capability topology.&lt;/p&gt;
&lt;p&gt;This is strictly stronger than nominal invocation.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;relational-navigation-beats-nominal-invocation&quot;&gt;Relational Navigation Beats Nominal Invocation&lt;/h3&gt;
&lt;p&gt;LLMs are good at resolving names.&lt;/p&gt;
&lt;p&gt;They are bad at:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Systematic search  &lt;/li&gt;
&lt;li&gt;Relational exploration  &lt;/li&gt;
&lt;li&gt;Topological disambiguation  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;A formal language enables:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Search through capability graphs  &lt;/li&gt;
&lt;li&gt;Context-aware narrowing  &lt;/li&gt;
&lt;li&gt;Progressive discovery  &lt;/li&gt;
&lt;li&gt;Authorization by construction  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is not “autocomplete”.&lt;/p&gt;
&lt;p&gt;This is &lt;strong&gt;relational observation over a formal structure&lt;/strong&gt;.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-implementation-is-already-known&quot;&gt;The Implementation Is Already Known&lt;/h3&gt;
&lt;p&gt;Asynchronous parsing is not new.&lt;/p&gt;
&lt;p&gt;Generators:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Exist in JavaScript for over a decade  &lt;/li&gt;
&lt;li&gt;Are foundational in operating systems  &lt;/li&gt;
&lt;li&gt;Are widely used in parsers and schedulers  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;They are exactly the right abstraction:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Incremental  &lt;/li&gt;
&lt;li&gt;Stateful  &lt;/li&gt;
&lt;li&gt;Deterministic  &lt;/li&gt;
&lt;li&gt;Interruptible  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Nothing exotic is required.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;the-critical-difference&quot;&gt;The Critical Difference&lt;/h3&gt;
&lt;p&gt;The most important outcome of such a system is this:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;It can correctly deny you access.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This places it in a completely different category than LLM-driven systems.&lt;/p&gt;
&lt;p&gt;LLMs aim to be helpful.&lt;br&gt;
Formal systems aim to be correct.&lt;/p&gt;
&lt;p&gt;When invoking real capabilities, correctness wins.&lt;/p&gt;
&lt;hr&gt;
&lt;h3 id=&quot;closing&quot;&gt;Closing&lt;/h3&gt;
&lt;p&gt;Dynamically generated languages and centralized capability graphs solve the same class of problems as MCP servers.&lt;/p&gt;
&lt;p&gt;They do so:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Deterministically  &lt;/li&gt;
&lt;li&gt;Safely  &lt;/li&gt;
&lt;li&gt;Transparently  &lt;/li&gt;
&lt;li&gt;With better UX  &lt;/li&gt;
&lt;li&gt;And with lower long-term complexity  &lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This is not the future of “AI interfaces”.&lt;/p&gt;
&lt;p&gt;This is the future of &lt;strong&gt;intent architecture&lt;/strong&gt;.&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/9963/dynamically-generated-languages-solve-the-same-class-problems-mcp-servers-and-it-better</guid>
<pubDate>Sun, 18 Jan 2026 18:03:10 +0000</pubDate>
</item>
</channel>
</rss>