JsonString to Object in VB6 - json

So I need to convert following response from Httprequest of JsonString to Object. Can someone help in looping it to an object. [New to Vb6]
Please see the below Json response.
{
"Participants": [
{
"Participant": {
"EntityHierarchy": {},
"ProviderPlatform": "string",
"ProviderPlatformDetail": [
{
"ProviderPlatform": "string",
"Primary": true
}
],
"FirstName": "string",
"LastName": "string",
"BusinessName": "string",
"City": "string",
"Region": "string",
"PostalCode": "string",
"Phone": "string",
"CountryCode": "string",
"Email": "string",
"AccountNumber": "string",
"Active": true,
"PSuiteAttribute": "string",
"ParticipantIdentifier": "string",
"SystemParticipantIdentifier": "string",
"ITAIdentifier": "string"
},
"Platform": "string",
"Program": "string",
"ProgramFriendlyName": "string",
"EnterpriseServicesIdentifier": "string",
"IdentityMapped": true,
"MappedToMasterPlatform": true,
"MasterPlatform": "string",
"SupportingPlatform": "string",
"MasterPlatformName": "string",
"SupportingPlatformName": "string",
"FaultedMessages": [
"string"
]
}

Bruce McPherson makes heavy use of a class called cJobject to do JSON handling in VBA/VB6. cJobject is too big to fit in an answer, but you can get its current source code off GitHub. See also his usage notes.

There are plenty of JSON classes floating around written in VB6, VBA, or VB6 that is portable to VBA.
Here are a couple more:
JsonBag, Another JSON Parser/Generator
JNode - JSON revisited

Related

Reference value from state’s input, using JSONPath syntax in combination with a hard-coded string

Im creating a SSM document with a state machine, in the api parameter: Name.
I want to combine a value from the state’s input (InstanceID) with the hard-coded text EC2-PROD-WEBSRV-CP_RAM_SWAP-Document.
Im wondering if something like "key2.$": "$.inputValue[+hardcodedstring]" is possible.
So the final value will be i-013165f64447e25e0-EC2-PROD-WEBSRV-CP_RAM_SWAP-Document.
SSM CreateDocument schema:
{
"Attachments": [
{
"Key": "string",
"Name": "string",
"Values": [ "string" ]
}
],
"Content": "string",
"DisplayName": "string",
"DocumentFormat": "string",
"DocumentType": "string",
"Name": "string",
"Requires": [
{
"Name": "string",
"Version": "string"
}
],
"Tags": [
{
"Key": "string",
"Value": "string"
}
],
"TargetType": "string",
"VersionName": "string"
}
I read the documentation but It seems it is possible just one or the other option.
https://aws.amazon.com/blogs/compute/using-jsonpath-effectively-in-aws-step-functions/
Use the States.Format intrinsic function to interpolate the value into a string:
"key2.$": "States.Format('{}-EC2-PROD-WEBSRV-CP_RAM_SWAP-Document', $.inputValue)"

Azure Logic App: Take API JSON input and map values to keys within another JSON Object

I am making an API call that returns JSON in the beneath format:
{
"query_status": "ok",
"data": [
{
"id": "41",
"ioc": "gaga.com",
"threat_type": "botnet_cc",
"threat_type_desc": "Indicator that identifies a botnet command&control server (C&C)",
"ioc_type": "domain",
},
[...]
}
I am looking for a solution whereby I can take these values and append them to a table in Azure. I need to assign some these values to the beneath:
{
"emailSenderName": "String",
"emailSourceDomain": "String",
"emailSourceIpAddress": "String",
"emailSubject": "String",
"emailXMailer": "String",
"expirationDateTime": "String (timestamp)",
"externalId": "String",
"fileCompileDateTime": "String (timestamp)",
"fileCreatedDateTime": "String (timestamp)",
"fileHashType": "string",
"fileHashValue": "String",
"fileMutexName": "String",
"fileName": "String",
"filePacker": "String",
"filePath": "String",
"fileSize": 1024,
"fileType": "String",
"id": "String (identifier)",
"ingestedDateTime": "String (timestamp)",
"isActive": true,
"killChain": ["String"],
}
The desired output is to create the object shown on this link
https://learn.microsoft.com/en-us/graph/api/tiindicator-submittiindicators?view=graph-rest-beta&tabs=http
What is the best way to do this? After scanning through the MS documentation I haven't found anything that helps. Essentially what I'd like to do is change the keys.
Why don't you just use a compose action in the logic app like in this example:

Generate schema from json file using jq

I have a newline-delimited JSON file. Is it possible to generate a schema using a tool like jq? I've had some success with jq in the past but haven't done something as complicated as this.
Here's the format of the schema I'm aiming for: https://cloud.google.com/bigquery/docs/nested-repeated#example_schema. Notice that nesting is handled with a fields key of the parent, and arrays are handled with "mode": "repeated". (Any help with some sort of schema is greatly appreciated and I then can massage into this format).
Copying from the link above, I'd like to generate from this:
{"id":"1","first_name":"John","last_name":"Doe","dob":"1968-01-22","addresses":[{"status":"current","address":"123 First Avenue","city":"Seattle","state":"WA","zip":"11111","numberOfYears":"1"},{"status":"previous","address":"456 Main Street","city":"Portland","state":"OR","zip":"22222","numberOfYears":"5"}]}
...to...
[
{
"name": "id",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "first_name",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "last_name",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "dob",
"type": "DATE",
"mode": "NULLABLE"
},
{
"name": "addresses",
"type": "RECORD",
"mode": "REPEATED",
"fields": [
{
"name": "status",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "address",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "city",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "state",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "zip",
"type": "STRING",
"mode": "NULLABLE"
},
{
"name": "numberOfYears",
"type": "STRING",
"mode": "NULLABLE"
}
]
}
]
(ref BigQuery autodetect doesn't work with inconsistent json?, showing that I can't use the BigQuery autodetect because the items aren't the same. I'm fairly confident I can merge schemas together manually to create a superset)
Here's a simple recursive function that may help if you decide to roll your own:
def schema:
def isdate($v): $v | test("[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]");
def array($k;$v): {"name":$k,"type":"RECORD",mode:"REPEATED","fields":($v[0] | schema)};
def date($k): {"name":$k,"type":"DATE", mode:"NULLABLE"};
def string($k): {"name":$k,"type":"STRING",mode:"NULLABLE"};
def item($k;$v):
$v | if type == "array" then array($k;$v)
elif type == "string" and isdate($v) then date($k)
elif type == "string" then string($k)
else empty end;
[ to_entries[] | item(.key;.value) ]
;
schema
Try it online!
Any help with some sort of schema is greatly appreciated and I then can massage into this format
There is a schema-inference module written in jq at http://gist.github.com/pkoppstein/a5abb4ebef3b0f72a6ed but the inferred schemas are "structural" - they mirror the input JSON. For your sample, the inferred schema is as shown below. As you can see, it would be quite easy to transform this into the format you have in mind, except that extra work would be required to infer the mode values.
Please note that the above-mentioned module infers the "common schema" from an arbitrarily large "sample" of JSON documents. That is, it is a schema inference engine rather than simply a "schema generator".
The above link references a companion schema-checker named JESS, also written in jq. The "E" in "JESS" stands for "extended", signifying that the JESS schema language for specifying schemas allows complex constraints to be included.
{
"id": "string",
"first_name": "string",
"last_name": "string",
"dob": "string",
"addresses": [
{
"status": "string",
"address": "string",
"city": "string",
"state": "string",
"zip": "string",
"numberOfYears": "string"
}
]
}

Json schema field order

I know that fields listed in a json schema object have no defined order, since they are not an array, but I am looking for a way to be able to display them in the proper order in my application UI.
Workarounds I have found so far include things like using a different serializer, or even hard-coding a number into the field name.
I would like to come up with something that works with my current setup.
Hibernate, Spring Boot, and a react-app front end.
given this GET request:
/profile/personEntities
with header: Accept: application/schema+json
I will receive this:
{
"title": "Person entity",
"properties": {
"birthday": {
"title": "Birthday",
"readOnly": false,
"type": "string",
"format": "date-time"
},
"lastName": {
"title": "Last name",
"readOnly": false,
"type": "string"
},
"address": {
"title": "Address",
"readOnly": false,
"type": "string",
"format": "uri"
},
"firstName": {
"title": "First name",
"readOnly": false,
"type": "string"
},
"email": {
"title": "Email",
"readOnly": false,
"type": "string"
},
"cellPhone": {
"title": "Cell phone",
"readOnly": false,
"type": "string"
}
},
"requiredProperties": [
"firstName",
"lastName"
],
"definitions": {},
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema#"
}
I have tried adding #JsonProperty(index=2) to the field, but nothing changes.
Thank you much for any tips.
If you're using Jackson to handle your serialization/deserialization you can use #JsonPropertyOrder - from their docs:
// ensure that "id" and "name" are output before other properties
#JsonPropertyOrder({ "id", "name" })
// order any properties that don't have explicit setting using alphabetic order
#JsonPropertyOrder(alphabetic=true)
See: http://fasterxml.github.io/jackson-annotations/javadoc/2.3.0/com/fasterxml/jackson/annotation/JsonPropertyOrder.html

Correct Json Structure for IOS Swift with Rest API

What is correct JSON structure to get from IOS swift device where multiple occurrence of the info is need to be store. I have to store multiple address of a person out of which one is current where he is living. How should i accepts current occupancy in case of IOS app written in swift. I have used "iscurrent" for checking current and previous occupancy. Also please suggest what is the correct way to send this json information in get API. I am using below for post as well as get. In get sending current occupancy always on top.
{
"items": [
{
"address": "string",
"city": "string",
"suburb": "string",
"postcode": "string",
"moveindate": "string",
"landlordname": "string",
"landlordemail": "string",
"iscurrent": 0,
"occid": 0
}
]
}
Some suggested me to send as below after saving.
{
"items":
"iscurrent" = {
"address": "string",
"city": "string",
"suburb": "string",
"postcode": "string",
"moveindate": "string",
"landlordname": "string",
"landlordemail": "string",
"occid": 1
},
"previous" = [{
"address": "string",
"city": "string",
"suburb": "string",
"postcode": "string",
"moveindate": "string",
"landlordname": "string",
"landlordemail": "string",
"occid": 2
},{
"address": "string",
"city": "string",
"suburb": "string",
"postcode": "string",
"moveindate": "string",
"landlordname": "string",
"landlordemail": "string",
"occid": 3
},
]
}