mqscript_cjson_parse
Parse JSON strings into structured objects for use in mobile automation scripts, enabling data handling and manipulation during device control operations.
Instructions
Parse JSON string to object
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| jsonString | Yes | JSON string to parse | |
| resultVariable | No | Variable name to store parsed object | jsonObj |
Implementation Reference
- src/tools/plugin-commands.ts:24-35 (handler)The handler function that executes the tool logic: generates MQScript to parse JSON string into a variable.handler: async (args: { jsonString: string; resultVariable?: string }) => { const { jsonString, resultVariable = 'jsonObj' } = args; const script = `${resultVariable} = CJson.Parse("${jsonString}")`; return { content: [ { type: 'text', text: `Generated MQScript CJson parse command:\n\`\`\`\n${script}\n\`\`\`\n\nThis parses JSON string and stores result in "${resultVariable}".` } ] }; }
- src/tools/plugin-commands.ts:9-23 (schema)Input schema defining parameters for the tool.inputSchema: { type: 'object' as const, properties: { jsonString: { type: 'string', description: 'JSON string to parse' }, resultVariable: { type: 'string', description: 'Variable name to store parsed object', default: 'jsonObj' } }, required: ['jsonString'] },
- src/tools/plugin-commands.ts:6-36 (registration)The complete tool definition object for mqscript_cjson_parse, which is spread into the ALL_TOOLS registry in src/index.ts.parse: { name: 'mqscript_cjson_parse', description: 'Parse JSON string to object', inputSchema: { type: 'object' as const, properties: { jsonString: { type: 'string', description: 'JSON string to parse' }, resultVariable: { type: 'string', description: 'Variable name to store parsed object', default: 'jsonObj' } }, required: ['jsonString'] }, handler: async (args: { jsonString: string; resultVariable?: string }) => { const { jsonString, resultVariable = 'jsonObj' } = args; const script = `${resultVariable} = CJson.Parse("${jsonString}")`; return { content: [ { type: 'text', text: `Generated MQScript CJson parse command:\n\`\`\`\n${script}\n\`\`\`\n\nThis parses JSON string and stores result in "${resultVariable}".` } ] }; } },
- src/index.ts:32-61 (registration)Registration of all tools including CJsonCommands (containing mqscript_cjson_parse) into the ALL_TOOLS object used by MCP server handlers.const ALL_TOOLS = { // Basic Commands - 基础命令 ...TouchCommands, ...ControlCommands, ...ColorCommands, ...OtherCommands, // Standard Library - 标准库函数 ...MathFunctions, ...StringFunctions, ...TypeConversionFunctions, ...ArrayFunctions, // UI Commands - 界面命令 ...UIControlCommands, ...UIPropertyCommands, ...FloatingWindowCommands, // Extension Commands - 扩展命令 ...ElementCommands, ...DeviceCommands, ...PhoneCommands, ...SysCommands, // Plugin Commands - 插件命令 ...CJsonCommands, ...DateTimeCommands, ...FileCommands, ...TuringCommands, };