I don't think you'd be able to do that with deserializing to a Map<String, String>
like you currently are.
You could use JSON.deserializeUntyped()
and work with a Map<String, Object>
to be able to dive deeper into your deserialized json, but since you're working with an SObject
(even if it's from a different org), it'd be easier to just deserialize it as an Account
.
String myJson = '{"attributes":{"type":"Account","url":"/services/data/v47.0/sobjects/Account/0014T000005aLUrQAM"},"FieldId__c":"0010I00002Kyu2zQAB","Id":"0014T000005aLUrQAM"}}';
// The second argument to deserialize() tells it which object/class to expect
// It's going to be <SObject name, or Apex class name>.class
// The return type of deserialize() is always "Object", even though we told it what
// class to use to do the deserialization.
// Because of that, we also need to explicitly type-cast the result
Account acct = (Account)JSON.deserialize(myJson, Account.class);
You'd then access your target value the same way that you'd access any other field on an SObject, acct.FieldId__c
.
This does assume that your Account
object has a FieldId__c
field (that you have at least read access to) in the org that you're running this code in.
As long as you don't try to insert the deserialized account (the Id won't be valid in both the source and target orgs), and keep it strictly in memory, then things should work out fine.