JIMSMITH 1 Posted Wednesday at 06:01 AM (edited) Given the JSON object below. I want to update the value of a JSON Pair. Here are a few questions - 1) Is there a fast way to find the JSON details for fiddler@office365.com. Do I have to loop through the each of the 4 entries. and check the value. 2) I want to update the new_token value from "rice" to "beans". 3) How do I add a new pair after "current_token". - This is last because I can probably figure #3 it out for myself. Help is much appreciaded in advance. { "SPWORKDATA": { "DB_PARAMS": { "DriverID":"Oracle", "Port":"9060", "Monitorby":"", "MetaDefSchema":"False" }, "MAILCONFIGS": [ {"sole.heel@apple.com": { "clickid": "307663883943-8", "social": "weeklyreader", "account": "rick.flair@gmail.com", "new_token":"", "current_token":"1//0f1U7S6-TZ-_r6RtWc" } }, {"timmona@office365.com": { "clickid": "client_data2", "secret": "appsecret", "social": "timmon.ray@office365.com", "new_token":"scacral", "current_token":"refreshtoken" } }, {"bruce@office365.com": { "clickid": "client_data2", "secret": "appsecret", "social": "bruce.richards@office365.com", "new_token":"soapl", "current_token":"refreen" } }, {"fiddler@office365.com": { "clickid": "client_d89", "secret": "appsoul", "social": "karen.richards@office365.com", "new_token":"rice", "current_token":"old" } } ], "MEDIASERVER": { "Server": "192.162.2.185" }, "MSGSERVER": { "Server": "127.0.0.1", "Port":"55555" } } Edited Wednesday at 01:11 PM by JIMSMITH Add commas per comment. Share this post Link to post
Der schöne Günther 323 Posted Wednesday at 09:40 AM Did you forget a comma , before your "new_token": or is there really none? Share this post Link to post
JIMSMITH 1 Posted Wednesday at 01:13 PM Apologies. There are supposed to be commas. I have added. Thanks. I made manual changes to for illustration purposes and make my 1st mistake. Share this post Link to post
Der schöne Günther 323 Posted Wednesday at 02:17 PM It is a shame your MAILCONFIGS contains an array of objects that just contain another object. Normally, you would use JsonPath for that, but Delphi's JsonPath support is very limited. See: Query JSON documents with JSONPath – grijjy blog System.JSON.TJSONObject.FindValue - RAD Studio API Documentation Quote: "These operators do not support special expressions, they only support actual values (object properties or array indexes)." I am afraid you will have to find the MAILCONFIGS node, and then iterate through it via code. Share this post Link to post
JIMSMITH 1 Posted yesterday at 05:06 AM Thanks for the information. An interesting read. Share this post Link to post