Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix the path lookup for objects so that it can handle quoted identifier names and non-alphanumerics in the identifier. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | json |
Files: | files | file ages | folders |
SHA1: |
87f5873004f69396baa7c67937342b4e |
User & Date: | drh 2015-08-19 23:02:49.082 |
Context
2015-08-20
| ||
23:39 | Merge the latest changes from trunk, including the table-valued function implementation. (check-in: 10c444322f user: drh tags: json) | |
2015-08-19
| ||
23:02 | Fix the path lookup for objects so that it can handle quoted identifier names and non-alphanumerics in the identifier. (check-in: 87f5873004 user: drh tags: json) | |
22:47 | Add the json_each(JSON,PATH) table-valued-function. (check-in: 3335ac17bb user: drh tags: json) | |
Changes
Changes to ext/misc/json.c.
︙ | ︙ | |||
699 700 701 702 703 704 705 | */ static JsonNode *jsonLookup( JsonParse *pParse, /* The JSON to search */ u32 iRoot, /* Begin the search at this node */ const char *zPath, /* The path to search */ int *pApnd /* Append nodes to complete path if not NULL */ ){ | | > > > > > | > > > > > | | | | 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 | */ static JsonNode *jsonLookup( JsonParse *pParse, /* The JSON to search */ u32 iRoot, /* Begin the search at this node */ const char *zPath, /* The path to search */ int *pApnd /* Append nodes to complete path if not NULL */ ){ u32 i, j, k, nKey; const char *zKey; JsonNode *pRoot = &pParse->aNode[iRoot]; if( zPath[0]==0 ) return pRoot; if( zPath[0]=='.' ){ if( pRoot->eType!=JSON_OBJECT ) return 0; zPath++; if( zPath[0]=='"' ){ zKey = zPath + 1; for(i=1; zPath[i] && zPath[i]!='"'; i++){} nKey = i-1; if( zPath[i] ) i++; }else{ zKey = zPath; for(i=0; zPath[i] && zPath[i]!='.' && zPath[i]!='['; i++){} nKey = i; } if( nKey==0 ) return 0; j = 1; for(;;){ while( j<=pRoot->n ){ if( pRoot[j].n==nKey+2 && strncmp(&pRoot[j].u.zJContent[1],zKey,nKey)==0 ){ return jsonLookup(pParse, iRoot+j+1, &zPath[i], pApnd); } j++; j += jsonSize(&pRoot[j]); } if( (pRoot->jnFlags & JNODE_APPEND)==0 ) break; |
︙ | ︙ |