I've stumbled uppon a JSON matching behaviour that doesn't make sense for me at all, because if I execute my feature via parallel runner, the matching fails (which shouldn't). But if I run the feature standalone (in IntelliJ, run feature), the matching succeeds as expected. I am almost losing my mind over this. :)
This is the actual response I get from an REST call:
[
{
"servicePointInfo": {
"cplID": "CPL123",
"klsID": 26035132,
"type": "Gebaeudeteil",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": null,
"surname": null,
"MSN0": null
}
},
"buildingInfo": {
"type": null,
"typeText": null,
"part": "FeH",
"partText": "Fernsprechh�uschen",
"partNumber": null,
"partInfo": "vor Telekom",
"partAlignment": null,
"level": null,
"levelText": null,
"levelNumber": null,
"floor": null,
"floorText": null,
"flatNumber": null,
"flatInfo": null
}
},
{
"servicePointInfo": {
"cplID": "CPL456",
"klsID": 26035132,
"type": "Wohnung",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": "Karl",
"surname": "Schaefer",
"MSN0": null
}
},
"buildingInfo": {
"type": "M",
"typeText": "Mehrfamilienhaus",
"part": null,
"partText": null,
"partNumber": null,
"partInfo": null,
"partAlignment": null,
"level": "EG",
"levelText": "Erdgescho�",
"levelNumber": null,
"floor": "R",
"floorText": "rechts",
"flatNumber": "12",
"flatInfo": null
}
},
{
"servicePointInfo": {
"cplID": "CPL789",
"klsID": 26035132,
"type": "Gebaeudeteil",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": null,
"surname": null,
"MSN0": null
}
},
"buildingInfo": {
"type": null,
"typeText": null,
"part": "VH",
"partText": "Vorderhaus",
"partNumber": null,
"partInfo": "gelbe Haus mit dem h�sslichen Dach",
"partAlignment": null,
"level": null,
"levelText": null,
"levelNumber": null,
"floor": null,
"floorText": null,
"flatNumber": null,
"flatInfo": null
}
}
]
And this is the JSON I use for matching. It's actually the copied actual response with some fuzzy matching expressions I used because I thought the special chars (ä, ß) could be the problem):
[
{
"servicePointInfo": {
"cplID": "CPL123",
"klsID": 26035132,
"type": "Gebaeudeteil",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": null,
"surname": null,
"MSN0": null
}
},
"buildingInfo": {
"type": null,
"typeText": null,
"part": "FeH",
"partText": "#notnull",
"partNumber": null,
"partInfo": "vor Telekom",
"partAlignment": null,
"level": null,
"levelText": null,
"levelNumber": null,
"floor": null,
"floorText": null,
"flatNumber": null,
"flatInfo": null
}
},
{
"servicePointInfo": {
"cplID": "CPL456",
"klsID": 26035132,
"type": "Wohnung",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": "Karl",
"surname": "Schaefer",
"MSN0": null
}
},
"buildingInfo": {
"type": "M",
"typeText": "Mehrfamilienhaus",
"part": null,
"partText": null,
"partNumber": null,
"partInfo": null,
"partAlignment": null,
"level": "EG",
"levelText": "#notnull",
"levelNumber": null,
"floor": "R",
"floorText": "rechts",
"flatNumber": "12",
"flatInfo": null
}
},
{
"servicePointInfo": {
"cplID": "CPL789",
"klsID": 26035132,
"type": "Gebaeudeteil",
"state": "FREI",
"stateText": "Freier Service Point",
"plannedDisconnectDate": null,
"recentInfo": {
"firstName": null,
"surname": null,
"MSN0": null
}
},
"buildingInfo": {
"type": null,
"typeText": null,
"part": "VH",
"partText": "Vorderhaus",
"partNumber": null,
"partInfo": "#notnull",
"partAlignment": null,
"level": null,
"levelText": null,
"levelNumber": null,
"floor": null,
"floorText": null,
"flatNumber": null,
"flatInfo": null
}
}
]
This is the matching result:
com.intuit.karate.exception.KarateException: path: $, actual: '[{"servicePointInfo":{"cplID":"CPL123","klsID":26035132,"type":"Gebaeudeteil","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":null,"surname":null,"MSN0":null}},"buildingInfo":{"type":null,"typeText":null,"part":"FeH","partText":"Fernsprechh�uschen","partNumber":null,"partInfo":"vor Telekom","partAlignment":null,"level":null,"levelText":null,"levelNumber":null,"floor":null,"floorText":null,"flatNumber":null,"flatInfo":null}},{"servicePointInfo":{"cplID":"CPL456","klsID":26035132,"type":"Wohnung","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":"Karl","surname":"Schaefer","MSN0":null}},"buildingInfo":{"type":"M","typeText":"Mehrfamilienhaus","part":null,"partText":null,"partNumber":null,"partInfo":null,"partAlignment":null,"level":"EG","levelText":"Erdgescho�","levelNumber":null,"floor":"R","floorText":"rechts","flatNumber":"12","flatInfo":null}},{"servicePointInfo":{"cplID":"CPL789","klsID":26035132,"type":"Gebaeudeteil","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":null,"surname":null,"MSN0":null}},"buildingInfo":{"type":null,"typeText":null,"part":"VH","partText":"Vorderhaus","partNumber":null,"partInfo":"gelbe Haus mit dem h�sslichen Dach","partAlignment":null,"level":null,"levelText":null,"levelNumber":null,"floor":null,"floorText":null,"flatNumber":null,"flatInfo":null}}]', expected: '[{"servicePointInfo":{"cplID":"CPL123","klsID":26035132,"type":"Gebaeudeteil","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":null,"surname":null,"MSN0":null}},"buildingInfo":{"type":null,"typeText":null,"part":"FeH","partText":"#notnull","partNumber":null,"partInfo":"vor Telekom","partAlignment":null,"level":null,"levelText":null,"levelNumber":null,"floor":null,"floorText":null,"flatNumber":null,"flatInfo":null}},{"servicePointInfo":{"cplID":"CPL456","klsID":26035132,"type":"Wohnung","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":"Karl","surname":"Schaefer","MSN0":null}},"buildingInfo":{"type":"M","typeText":"Mehrfamilienhaus","part":null,"partText":null,"partNumber":null,"partInfo":null,"partAlignment":null,"level":"EG","levelText":"#notnull","levelNumber":null,"floor":"R","floorText":"rechts","flatNumber":"12","flatInfo":null}},{"servicePointInfo":{"cplID":"CPL789","klsID":26035132,"type":"Gebaeudeteil","state":"FREI","stateText":"Freier Service Point","plannedDisconnectDate":null,"recentInfo":{"firstName":null,"surname":null,"MSN0":null}},"buildingInfo":{"type":null,"typeText":null,"part":"VH","partText":"Vorderhaus","partNumber":null,"partInfo":"#notnull","partAlignment":null,"level":null,"levelText":null,"levelNumber":null,"floor":null,"floorText":null,"flatNumber":null,"flatInfo":null}}]', reason: not equal
Someone experience such a behaviour as well?
cheers
--Edit due to the answer of #Peter--
This is my current build.gradle:
version '1.0-SNAPSHOT'
apply plugin: 'java'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
sourceSets {
test {
resources {
srcDir file('src/test/java')
exclude '**/*.java'
}
}
}
dependencies {
testCompile('com.intuit.karate:karate-apache:0.8.0.RC3')
testCompile('com.intuit.karate:karate-junit4:0.8.0.RC3')
testCompile('net.masterthought:cucumber-reporting:3.8.0')
testCompile('org.apache.commons:commons-text:1.3')
testCompile('com.googlecode.json-simple:json-simple:1.1.1')
}
test.dependsOn clean
No worries, forcing the maven surefire plugin to UTF-8 should fix this problem, documented here: https://github.com/intuit/karate#fileencoding
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.10</version>
<configuration>
<argLine>-Dfile.encoding=UTF-8</argLine>
</configuration>
</plugin>
Related
anybody know why restful api scan has data
http://127.0.0.1:8080/ignite?cmd=qryscanexe&pageSize=5&cacheName=contact
result
{
"successStatus": 0,
"error": null,
"sessionToken": null,
"response": {
"items": [
{
"key": {
"id": 703896957108224
},
"value": {
"mergedId": null,
"priority": 0,
"identities": [
{
"id": "7",
"type": "idCard",
"dateCreated": 1652932875433,
"lastUpdated": 1652932875433
}
],
"followerIds": [],
"contactType": "LEADER",
"dateCreated": 1652932875433,
"lastUpdated": 1652932875433
}
}
],
"last": true,
"queryId": 2,
"fieldsMetadata": [
{
"schemaName": null,
"typeName": null,
"fieldName": "key",
"fieldTypeName": null
},
{
"schemaName": null,
"typeName": null,
"fieldName": "value",
"fieldTypeName": null
}
]
}
}.
but get command no result.
http://127.0.0.1:8080/ignite?cacheName=contact&cmd=get&keyType=ContactKey&key={"id":703896957108224}
result
{
"successStatus": 0,
"affinityNodeId": "ee5e4d0d-5c91-4b9d-b68f-5dfac2f45908",
"error": null,
"sessionToken": null,
"response": null
}
By default Ignite REST supports Java built-in types for get/put operations. But it should be possible to implement a custom serialization if needed. In general it's much better to use Ignite thin clients, it's more functional than REST.
I have created an account on jdoodle and buy a free plan in which we can make 200 requests per days and from there I got credentials (clientId and clientSecret) for making request to their api .
I am making post request from postman to Jdoodle api. It is giving me response as unauthorized request with status code 401 in spite of valid credentials.
Giving me unauthorised request error also when i make request for checking credits used or (how many calls I have made to their api).
POST- https://api.jdoodle.com/v1/execute/
{
"clientID" : "83xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"clientSecret" : "30xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"script" : "console.log('hello')",
"language" : "nodejs",
"versionIndex" : "0"
}
Response I am getting is -
{
"error": "Unauthorized Request",
"statusCode": 401
}
POST- https://api.jdoodle.com/v1/credit-spent
{
"clientID" : "83xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"clientSecret" : "30xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
}
Response I am getting is -
{
"error": "Unauthorized Request",
"statusCode": 401
}
I don't know why I am getting such response inspite of all valid credentials and parameters.
Use this postman collection. Mostly it looks like your issue is with auth. make sure if client_id and secret are safely substituted.
{
"auth": null,
"event": null,
"info": {
"_postman_id": null,
"description": null,
"name": "JDoodle Compiler API.http",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"version": null
},
"item": [
{
"description": null,
"event": null,
"id": null,
"name": "Execute Program",
"protocolProfileBehavior": null,
"request": {
"auth": null,
"body": {
"disabled": null,
"file": null,
"formdata": null,
"graphql": null,
"mode": "raw",
"options": {
"language": "json"
},
"raw": "{\"clientId\": \"{{clientId}}\", \"clientSecret\": \"{{clientSecret}}\", \"script\": \"print 'hello'\", \"language\": \"python2\", \"versionIndex\": \"0\"}",
"urlencoded": null
},
"certificate": null,
"description": "Execute Program",
"header": [
{
"description": null,
"disabled": false,
"key": "content-type",
"value": "application/json"
}
],
"method": "POST",
"proxy": null,
"url": "https://api.jdoodle.com/v1/execute/"
},
"response": null,
"variable": null,
"auth": null,
"item": null
}
],
"protocolProfileBehavior": null,
"variable": [
{
"description": null,
"disabled": false,
"id": null,
"key": "baseUrl",
"name": null,
"system": null,
"type": null,
"value": "httpsDefaultParameterValue:DefaultParameterValue#DefaultParameterValue.myshopify.com/"
},
{
"description": null,
"disabled": false,
"id": null,
"key": "id",
"name": null,
"system": null,
"type": null,
"value": "<post>"
},
{
"description": null,
"disabled": false,
"id": null,
"key": "event_id",
"name": null,
"system": null,
"type": null,
"value": "<>"
}
]
}
With dothttp request is far simple and easily sharable
#name("Execute Program")
POST "https://api.jdoodle.com/v1/execute/"
json({
"clientId": "{{clientId}}",
"clientSecret": "{{clientSecret}}",
// "script": '<?php echo "hello"; ?>',
// "language": "php",
"script" :"print 'hello'",
"language": "python2",
// "stdin": "",
"versionIndex": "0"
})
Edit: #mathguy has already correctly pointed out that I need to use JSON_ARRAYAGG to have this correctly handle multi-row data. However, I still have an outstanding issue with the lastName object not returning speechmarks. Can anyone advise why this might be, from the SQL below? Many thanks.
I have a requirement to generate JSON to insert data for lots of customers via an API. This contains JSON arrays (one overarching array for all customers and an array for potential multiple addresses) and objects. The code I'm currently using produces this:
[
{
"address": [
{
"addressLine1": "ALLIANCE & LEICESTER PLC",
"addressLine2": "CUSTOMER SERVICES",
"addressLine3": "CARLTON PARK",
"region": "LEICESTERSHIRE",
"city": "LEICESTER",
"zip": "LE190AL",
"type": "residential"
},
{
"addressLine1": null,
"addressLine2": null,
"addressLine3": null,
"region": null,
"city": null,
"zip": null,
"type": null
}
],
"firstName": "SIOBHAN",
"lastName":TOWNSEND
}
]
[
{
"address": [
{
"addressLine1": "VIA DE LOS POBLADOS 2",
"addressLine2": null,
"addressLine3": null,
"region": null,
"city": "MADRID",
"zip": "28033",
"type": "residential"
},
{
"addressLine1": null,
"addressLine2": null,
"addressLine3": null,
"region": null,
"city": null,
"zip": null,
"type": null
}
],
"firstName": "HAYDEN",
"lastName":THOMSON
}
]
[
{
"address": [
{
"addressLine1": "VIA DE LOS POBLADOS 1",
"addressLine2": null,
"addressLine3": null,
"region": null,
"city": "MADRID",
"zip": "28034",
"type": "residential"
},
{
"addressLine1": null,
"addressLine2": null,
"addressLine3": null,
"region": null,
"city": null,
"zip": null,
"type": null
}
],
"firstName": "MADISON",
"lastName":FROST
}
]
...however I need it to look like this:
[
{
"address": [
{
"addressLine1": "ALLIANCE & LEICESTER PLC",
"addressLine2": "CUSTOMER SERVICES",
"addressLine3": "CARLTON PARK",
"region": "LEICESTERSHIRE",
"city": "LEICESTER",
"zip": "LE190AL",
"type": "residential"
},
{
"addressLine1": null,
"addressLine2": null,
"addressLine3": null,
"region": null,
"city": null,
"zip": null,
"type": null
}
],
"firstName": "SIOBHAN",
"lastName": "TOWNSEND"
},
{
"address": [
{
"addressLine1": "VIA DE LOS POBLADOS 2",
"addressLine2": null,
"addressLine3": null,
"region": null,
"city": "MADRID",
"zip": "28033",
"type": "residential"
},
{
"addressLine1": null,
"addressLine2": null,
"addressLine3": null,
"region": null,
"city": null,
"zip": null,
"type": null
}
],
"firstName": "HAYDEN",
"lastName": "THOMSON"
},
{
"address": [
{
"addressLine1": "VIA DE LOS POBLADOS 1",
"addressLine2": null,
"addressLine3": null,
"region": null,
"city": "MADRID",
"zip": "28034",
"type": "residential"
},
{
"addressLine1": null,
"addressLine2": null,
"addressLine3": null,
"region": null,
"city": null,
"zip": null,
"type": null
}
],
"firstName": "MADISON",
"lastName": "FROST"
}
]
The key differences here being:
The overarching array should start at the beginning of the 1st record and finish at the end of the last record, rather than ending after every "row"
For some reason, the last object in the list (lastName) doesn't have its value correctly listed in speechmarks
A comma separator should appear between each customer/row
This is the SQL I have been running:
SELECT
json_array(
json_object('address' VALUE
json_array(json_object('addressLine1' VALUE address.line_1,
'addressLine2' VALUE address.line_2,
'addressLine3' VALUE address.line_3,
'region' VALUE address.county,
'city' VALUE address.town,
'zip' VALUE address.postcode,
'type' VALUE 'residential'),
json_object('addressLine1' VALUE correspondence_address.line_1,
'addressLine2' VALUE correspondence_address.line_2,
'addressLine3' VALUE correspondence_address.line_3,
'region' VALUE correspondence_address.county,
'city' VALUE correspondence_address.town,
'zip' VALUE correspondence_address.postcode,
'type' VALUE case when person.correspondence_address_id is null then null else 'correspondence' end)
),
'firstName' VALUE person.first_name,
'lastName' VALUE person.surname
FORMAT JSON)
)as customer_json
FROM
person,
address,
address correspondence_address
WHERE
person.address_id=address.id
and person.correspondence_address_id=correspondence_address.id(+)
This is being run against an Oracle 19c database. Can anyone help me to troubleshoot if it's possible to set a JSON_ARRAY to wrap around the full dataset, rather than it ending and restarting after each customer record?
Credit to #mathguy for correctly pointing out that I needed to use JSON_ARRAYAGG in order to get the SQL to correctly handle multiple rows.
I have realised that I needed to remove the "FORMAT JSON" from the end as this trailed from the lastName variable and impacted the way it was returned. Removing this fixed my issue. Here is the working code:
SELECT
json_arrayagg(json_object('address' VALUE
json_array(json_object('addressLine1' VALUE address.line_1,
'addressLine2' VALUE address.line_2,
'addressLine3' VALUE address.line_3,
'region' VALUE address.county,
'city' VALUE address.town,
'zip' VALUE address.postcode,
'type' VALUE 'residential'),
json_object('addressLine1' VALUE correspondence_address.line_1,
'addressLine2' VALUE correspondence_address.line_2,
'addressLine3' VALUE correspondence_address.line_3,
'region' VALUE correspondence_address.county,
'city' VALUE correspondence_address.town,
'zip' VALUE correspondence_address.postcode,
'type' VALUE case when person.correspondence_address_id is null then null else 'correspondence' end)
),
'firstName' VALUE person.first_name,
'lastName' VALUE person.surname
))as customer_json
FROM
person,
address,
address correspondence_address
WHERE
person.address_id=address.id
and person.correspondence_address_id=correspondence_address.id(+)
Thanks in advance for any help. This is killing me! :-)
I have a JSON string that has an object collection nested within it that I need to get a standard SQL result set from. Here is a sample string of the JSON I am working with:
{
"ST": {
"TransactionSetIdentifierCode_01": "835",
"TransactionSetControlNumber_02": "1740",
"ImplementationConventionPreference_03": null
},
"BPR_FinancialInformation": {
"TransactionHandlingCode_01": "I",
"TotalPremiumPaymentAmount_02": "45.75",
"CreditorDebitFlagCode_03": "C",
"PaymentMethodCode_04": "ACH",
"PaymentFormatCode_05": "CCP",
"DepositoryFinancialInstitutionDFIIdentificationNumberQualifier_06": "01",
"OriginatingDepositoryFinancialInstitutionDFIIdentifier_07": "111",
"AccountNumberQualifier_08": "DA",
"SenderBankAccountNumber_09": "33",
"PayerIdentifier_10": "1234567890",
"OriginatingCompanySupplementalCode_11": null,
"DepositoryFinancialInstitutionDFIIdentificationNumberQualifier_12": "01",
"ReceivingDepositoryFinancialInstitutionDFIIdentifier_13": "111",
"AccountNumberQualifier_14": "DA",
"ReceiverBankAccountNumber_15": "22",
"CheckIssueorEFTEffectiveDate_16": "20100101",
"BusinessFunctionCode_17": null,
"DFIIDNumberQualifier_18": null,
"DFIIdentificationNumber_19": null,
"AccountNumberQualifier_20": null,
"AccountNumber_21": null
},
"TRN_ReassociationTraceNumber": {
"TraceTypeCode_01": "1",
"CurrentTransactionTraceNumber_02": "10100000000",
"OriginatingCompanyIdentifier_03": "1000000000",
"ReferenceIdentification_04": null
},
"CUR_ForeignCurrencyInformation": null,
"AllREF": {
"REF_ReceiverIdentification": {
"ReferenceIdentificationQualifier_01": "EV",
"MemberGrouporPolicyNumber_02": "ETIN",
"Description_03": null,
"ReferenceIdentifier_04": null
},
"REF_VersionIdentification": null
},
"DTM_ProductionDate": {
"DateTimeQualifier_01": "405",
"Date_02": "20100101",
"Time_03": null,
"TimeCode_04": null,
"DateTimePeriodFormatQualifier_05": null,
"DateTimePeriod_06": null
},
"AllN1": {
"Loop1000A": {
"N1_PayerIdentification": {
"EntityIdentifierCode_01": "PR",
"PremiumPayerName_02": "NYSDOH",
"IdentificationCodeQualifier_03": null,
"IntermediaryBankIdentifier_04": null,
"EntityRelationshipCode_05": null,
"EntityIdentifierCode_06": null
},
"N3_PayerAddress": {
"ResponseContactAddressLine_01": "OFFICE OF HEALTH INSURANCE PROGRAMS",
"ResponseContactAddressLine_02": "CORNING TOWER, EMPIRE STATE PLAZA"
},
"N4_PayerCity_State_ZIPCode": {
"AdditionalPatientInformationContactCityName_01": "ALBANY",
"AdditionalPatientInformationContactStateCode_02": "NY",
"AdditionalPatientInformationContactPostalZoneorZIPCode_03": "122370080",
"CountryCode_04": null,
"LocationQualifier_05": null,
"LocationIdentifier_06": null,
"CountrySubdivisionCode_07": null
},
"REF_AdditionalPayerIdentification": null,
"AllPER": {
"PER_PayerBusinessContactInformation": null,
"PER_PayerTechnicalContactInformation": [
{
"ContactFunctionCode_01": "BL",
"ResponseContactName_02": "PROVIDER SERVICES",
"CommunicationNumberQualifier_03": "TE",
"ResponseContactCommunicationNumber_04": "8003439000",
"CommunicationNumberQualifier_05": "UR",
"ResponseContactCommunicationNumber_06": "www.emedny.org",
"CommunicationNumberQualifier_07": null,
"ResponseContactCommunicationNumber_08": null,
"ContactInquiryReference_09": null
}
],
"PER_PayerWEBSite": null
}
},
"Loop1000B": {
"N1_PayeeIdentification": {
"EntityIdentifierCode_01": "PE",
"PremiumPayerName_02": "MAJOR MEDICAL PROVIDER",
"IdentificationCodeQualifier_03": "XX",
"IntermediaryBankIdentifier_04": "9999999995",
"EntityRelationshipCode_05": null,
"EntityIdentifierCode_06": null
},
"N3_PayeeAddress": null,
"N4_PayeeCity_State_ZIPCode": null,
"REF_PayeeAdditionalIdentification": [
{
"ReferenceIdentificationQualifier_01": "TJ",
"MemberGrouporPolicyNumber_02": "000000000",
"Description_03": null,
"ReferenceIdentifier_04": null
}
],
"RDM_RemittanceDeliveryMethod": null
}
},
"Loop2000": [
{
"LX_HeaderNumber": {
"AssignedNumber_01": "1"
},
"TS3_ProviderSummaryInformation": null,
"TS2_ProviderSupplementalSummaryInformation": null,
"Loop2100": [
{
"CLP_ClaimPaymentInformation": {
"PatientControlNumber_01": "PATIENT ACCOUNT NUMBER",
"ClaimStatusCode_02": "1",
"TotalClaimChargeAmount_03": "34.25",
"ClaimPaymentAmount_04": "34.25",
"PatientResponsibilityAmount_05": null,
"ClaimFilingIndicatorCode_06": "MC",
"PayerClaimControlNumber_07": "1000210000000030",
"FacilityTypeCode_08": "11",
"ClaimFrequencyCode_09": null,
"PatientStatusCode_10": null,
"DiagnosisRelatedGroupDRGCode_11": null,
"DiagnosisRelatedGroupDRGWeight_12": null,
"DischargeFraction_13": null,
"YesNoConditionorResponseCode_14": null
},
"CAS_ClaimsAdjustment": null,
"AllNM1": {
"NM1_PatientName": {
"EntityIdentifierCode_01": "QC",
"EntityTypeQualifier_02": "1",
"ResponseContactLastorOrganizationName_03": "SUBMITTED LAST",
"ResponseContactFirstName_04": "SUBMITTED FIRST",
"ResponseContactMiddleName_05": null,
"NamePrefix_06": null,
"ResponseContactNameSuffix_07": null,
"IdentificationCodeQualifier_08": "MI",
"ResponseContactIdentifier_09": "LL99999L",
"EntityRelationshipCode_10": null,
"EntityIdentifierCode_11": null,
"NameLastorOrganizationName_12": null
},
"NM1_InsuredName": null,
"NM1_CorrectedPatient_InsuredName": {
"EntityIdentifierCode_01": "74",
"EntityTypeQualifier_02": "1",
"ResponseContactLastorOrganizationName_03": "CORRECTED LAST",
"ResponseContactFirstName_04": "CORRECTED FIRST",
"ResponseContactMiddleName_05": null,
"NamePrefix_06": null,
"ResponseContactNameSuffix_07": null,
"IdentificationCodeQualifier_08": null,
"ResponseContactIdentifier_09": null,
"EntityRelationshipCode_10": null,
"EntityIdentifierCode_11": null,
"NameLastorOrganizationName_12": null
},
"NM1_ServiceProviderName": null,
"NM1_CrossoverCarrierName": null,
"NM1_CorrectedPriorityPayerName": null,
"NM1_OtherSubscriberName": null
},
"MIA_InpatientAdjudicationInformation": null,
"MOA_OutpatientAdjudicationInformation": null,
"AllREF": {
"REF_OtherClaimRelatedIdentification": [
{
"ReferenceIdentificationQualifier_01": "EA",
"MemberGrouporPolicyNumber_02": "PATIENT ACCOUNT NUMBER",
"Description_03": null,
"ReferenceIdentifier_04": null
}
],
"REF_RenderingProviderIdentification": null
},
"AllDTM": {
"DTM_StatementFromorToDate": [
{
"DateTimeQualifier_01": "232",
"Date_02": "20100101",
"Time_03": null,
"TimeCode_04": null,
"DateTimePeriodFormatQualifier_05": null,
"DateTimePeriod_06": null
},
{
"DateTimeQualifier_01": "233",
"Date_02": "20100101",
"Time_03": null,
"TimeCode_04": null,
"DateTimePeriodFormatQualifier_05": null,
"DateTimePeriod_06": null
}
],
"DTM_CoverageExpirationDate": null,
"DTM_ClaimReceivedDate": null
},
"PER_ClaimContactInformation": null,
"AMT_ClaimSupplementalInformation": [
{
"AmountQualifierCode_01": "AU",
"TotalClaimChargeAmount_02": "34.25",
"CreditDebitFlagCode_03": null
}
],
"QTY_ClaimSupplementalInformationQuantity": null,
"Loop2110": null
},
{
"CLP_ClaimPaymentInformation": {
"PatientControlNumber_01": "PATIENT ACCOUNT NUMBER",
"ClaimStatusCode_02": "2",
"TotalClaimChargeAmount_03": "34",
"ClaimPaymentAmount_04": "0",
"PatientResponsibilityAmount_05": null,
"ClaimFilingIndicatorCode_06": "MC",
"PayerClaimControlNumber_07": "1000220000000020",
"FacilityTypeCode_08": "11",
"ClaimFrequencyCode_09": null,
"PatientStatusCode_10": null,
"DiagnosisRelatedGroupDRGCode_11": null,
"DiagnosisRelatedGroupDRGWeight_12": null,
"DischargeFraction_13": null,
"YesNoConditionorResponseCode_14": null
},
"CAS_ClaimsAdjustment": null,
"AllNM1": {
"NM1_PatientName": {
"EntityIdentifierCode_01": "QC",
"EntityTypeQualifier_02": "1",
"ResponseContactLastorOrganizationName_03": "SUBMITTED LAST",
"ResponseContactFirstName_04": "SUBMITTED FIRST",
"ResponseContactMiddleName_05": null,
"NamePrefix_06": null,
"ResponseContactNameSuffix_07": null,
"IdentificationCodeQualifier_08": "MI",
"ResponseContactIdentifier_09": "LL88888L",
"EntityRelationshipCode_10": null,
"EntityIdentifierCode_11": null,
"NameLastorOrganizationName_12": null
},
"NM1_InsuredName": null,
"NM1_CorrectedPatient_InsuredName": {
"EntityIdentifierCode_01": "74",
"EntityTypeQualifier_02": "1",
"ResponseContactLastorOrganizationName_03": "CORRECTED LAST",
"ResponseContactFirstName_04": "CORRECTED FIRST",
"ResponseContactMiddleName_05": null,
"NamePrefix_06": null,
"ResponseContactNameSuffix_07": null,
"IdentificationCodeQualifier_08": null,
"ResponseContactIdentifier_09": null,
"EntityRelationshipCode_10": null,
"EntityIdentifierCode_11": null,
"NameLastorOrganizationName_12": null
},
"NM1_ServiceProviderName": null,
"NM1_CrossoverCarrierName": null,
"NM1_CorrectedPriorityPayerName": null,
"NM1_OtherSubscriberName": null
},
"MIA_InpatientAdjudicationInformation": null,
"MOA_OutpatientAdjudicationInformation": null,
"AllREF": {
"REF_OtherClaimRelatedIdentification": [
{
"ReferenceIdentificationQualifier_01": "EA",
"MemberGrouporPolicyNumber_02": "PATIENT ACCOUNT NUMBER",
"Description_03": null,
"ReferenceIdentifier_04": null
}
],
"REF_RenderingProviderIdentification": null
},
"AllDTM": {
"DTM_StatementFromorToDate": [
{
"DateTimeQualifier_01": "232",
"Date_02": "20100101",
"Time_03": null,
"TimeCode_04": null,
"DateTimePeriodFormatQualifier_05": null,
"DateTimePeriod_06": null
},
{
"DateTimeQualifier_01": "233",
"Date_02": "20100101",
"Time_03": null,
"TimeCode_04": null,
"DateTimePeriodFormatQualifier_05": null,
"DateTimePeriod_06": null
}
],
"DTM_CoverageExpirationDate": null,
"DTM_ClaimReceivedDate": null
},
"PER_ClaimContactInformation": null,
"AMT_ClaimSupplementalInformation": null,
"QTY_ClaimSupplementalInformationQuantity": null,
"Loop2110": null
},
{
"CLP_ClaimPaymentInformation": {
"PatientControlNumber_01": "PATIENT ACCOUNT NUMBER",
"ClaimStatusCode_02": "2",
"TotalClaimChargeAmount_03": "34.25",
"ClaimPaymentAmount_04": "11.5",
"PatientResponsibilityAmount_05": null,
"ClaimFilingIndicatorCode_06": "MC",
"PayerClaimControlNumber_07": "1000230000000020",
"FacilityTypeCode_08": "11",
"ClaimFrequencyCode_09": null,
"PatientStatusCode_10": null,
"DiagnosisRelatedGroupDRGCode_11": null,
"DiagnosisRelatedGroupDRGWeight_12": null,
"DischargeFraction_13": null,
"YesNoConditionorResponseCode_14": null
},
"CAS_ClaimsAdjustment": null,
"AllNM1": {
"NM1_PatientName": {
"EntityIdentifierCode_01": "QC",
"EntityTypeQualifier_02": "1",
"ResponseContactLastorOrganizationName_03": "SUBMITTED LAST",
"ResponseContactFirstName_04": "SUBMITTED FIRST",
"ResponseContactMiddleName_05": null,
"NamePrefix_06": null,
"ResponseContactNameSuffix_07": null,
"IdentificationCodeQualifier_08": "MI",
"ResponseContactIdentifier_09": "LL77777L",
"EntityRelationshipCode_10": null,
"EntityIdentifierCode_11": null,
"NameLastorOrganizationName_12": null
},
"NM1_InsuredName": null,
"NM1_CorrectedPatient_InsuredName": {
"EntityIdentifierCode_01": "74",
"EntityTypeQualifier_02": "1",
"ResponseContactLastorOrganizationName_03": "CORRECTED LAST",
"ResponseContactFirstName_04": "CORRECTED FIRST",
"ResponseContactMiddleName_05": null,
"NamePrefix_06": null,
"ResponseContactNameSuffix_07": null,
"IdentificationCodeQualifier_08": null,
"ResponseContactIdentifier_09": null,
"EntityRelationshipCode_10": null,
"EntityIdentifierCode_11": null,
"NameLastorOrganizationName_12": null
},
"NM1_ServiceProviderName": null,
"NM1_CrossoverCarrierName": null,
"NM1_CorrectedPriorityPayerName": null,
"NM1_OtherSubscriberName": null
},
"MIA_InpatientAdjudicationInformation": null,
"MOA_OutpatientAdjudicationInformation": null,
"AllREF": {
"REF_OtherClaimRelatedIdentification": [
{
"ReferenceIdentificationQualifier_01": "EA",
"MemberGrouporPolicyNumber_02": "PATIENT ACCOUNT NUMBER",
"Description_03": null,
"ReferenceIdentifier_04": null
}
],
"REF_RenderingProviderIdentification": null
},
"AllDTM": {
"DTM_StatementFromorToDate": [
{
"DateTimeQualifier_01": "232",
"Date_02": "20100101",
"Time_03": null,
"TimeCode_04": null,
"DateTimePeriodFormatQualifier_05": null,
"DateTimePeriod_06": null
},
{
"DateTimeQualifier_01": "233",
"Date_02": "20100101",
"Time_03": null,
"TimeCode_04": null,
"DateTimePeriodFormatQualifier_05": null,
"DateTimePeriod_06": null
}
],
"DTM_CoverageExpirationDate": null,
"DTM_ClaimReceivedDate": null
},
"PER_ClaimContactInformation": null,
"AMT_ClaimSupplementalInformation": [
{
"AmountQualifierCode_01": "AU",
"TotalClaimChargeAmount_02": "11.5",
"CreditDebitFlagCode_03": null
}
],
"QTY_ClaimSupplementalInformationQuantity": null,
"Loop2110": null
}
]
}
],
"PLB_ProviderAdjustment": null,
"SE": {
"NumberofIncludedSegments_01": "65",
"TransactionSetControlNumber_02": "1740"
},
"ErrorContext": {
"Name": "835",
"ControlNumber": "1740",
"Edition": "005010",
"Release": "X221A1",
"Index": 2,
"ValidatedSegmentsCount": 0,
"Codes": [],
"Errors": [
{
"Name": "SVC",
"Position": 20,
"LoopId": null,
"Value": "SVC*HC:V2020:RB*6*6**1",
"Codes": [
4
],
"Errors": [],
"Message": "Segment SVC*HC:V2020:RB*6 is not allowed in this position. Only the following segments can appear: AMT, QTY, SVC, CLP, LX, PLB, SE"
}
],
"HasErrors": true,
"Message": null
}
}
This string can be pasted into an online JSON parser to visualize the hierarchy more easily (like http://json.parser.online.fr/).
What I am trying to do is use the SQL Server OPENJSON function to get a result set of the 3 sample claims in this JSON string. The claims are nested in $.Loop2000.Loop2100, and the result I am trying to get is:
Patient Account Number ClaimStatusCode TotalClaimChargeAmount
------------------------------------------------------------------------
Patient Account Number 1 34.25
Patient Account Number 2 34.00
Patient Account Number 3 34.00
I can't seem to get the path right in the OPENJSON function to turn this into a result set with 3 rows. I am trying to use something like:
SELECT * FROM OPENJSON(#sJSON, N'$.Loop2000.Loop2100')
WITH (
PatientControlNumber_01 nvarchar(100) '$.CLP_ClaimPaymentInformation.PatientControlNumber_01'
)
Any help would be much appreciated.
One method you could use is a few nested OPNEJSON calls:
SELECT CPI.*
FROM OPENJSON(#JSON, N'$.Loop2000')
WITH (Loop2100 nvarchar(MAX) AS JSON) L2000
CROSS APPLY OPENJSON(L2000.Loop2100)
WITH(CLP_ClaimPaymentInformation nvarchar(MAX) AS JSON) L2100
CROSS APPLY OPENJSON(L2100.CLP_ClaimPaymentInformation)
WITH (PatientControlNumber varchar(100) '$.PatientControlNumber_01',
ClaimStatusCode int '$.ClaimStatusCode_02',
TotalClaimChargeAmount decimal(12,2) '$.TotalClaimChargeAmount_03') CPI;
Below is my JSON. I'm trying to create a tree out of this,
I tried with the following snippet:
require(["dijit/Tree", "dojo/data/ItemFileReadStore", "dijit/tree/ForestStoreModel", "dojo/domReady!"],
function(Tree, ItemFileReadStore, ForestStoreModel){
var store = new ItemFileReadStore({
url: "/om/web/em/tree.json"
});
var treeModel = new ForestStoreModel({
store: store,
query: {id: 'aid'},
rootId: "PSS-32",
rootLabel: "P",
childrenAttrs: ['eqList']
});
var myTree = new Tree({
model: treeModel
}, "treeOne");
myTree.startup();
});
But this is giving me error loading PSS010010026024 children and message: "Cannot read property 'length' of undefined errors,what should be specified in the rootID,rootLabel and childrenAttrs?
[
{
"responseStatus": null,
"entityType": "NODE",
"aid": "p",
"id": "p",
"hsa": null,
"eqList":[ {
"responseStatus": null,
"EId": "5",
"EGroupId": "1006",
"aid": "p",
"additionalInfo": null,
"eqList": [
{
"responseStatus": null,
"EId": null,
"EGroupId": null,
"aid": null,
"additionalInfo": null,
"eqList": null,
"shelfType": null,
"isEqAvailable": null,
"id": null,
"entityType": null,
"hsa": null,
"Elist": null
}
],
"shelfType": null,
"isEqAvailable": null,
"id": "p/p",
"entityType": "E",
"hsa": "-",
"Elist": null
{
"responseStatus": null,
"EId": "5",
"EGroupId": "1006",
"aid": "p#OCS",
"EType": "1830pss-ocs",
"ERelease": "7.0",
"additionalInfo": null,
"eqList": [
{
"responseStatus": null,
"EId": null,
"EGroupId": null,
"aid": null,
"EType": null,
"ERelease": null,
"additionalInfo": null,
"eqList": null,
"shelfType": null,
"isEqAvailable": null,
"id": null,
"entityType": null,
"hsa": null,
"Elist": null
}
],
"shelfType": null,
"isEqAvailable": null,
"id": "p/p#OCS",
"entityType": "E",
"hsa": "-",
"Elist": null
}
]
}
]
The rootID attribute is what ID you want to give the root item that will be created (so that you can query for it later or check if your tree is at the top level). The rootLabel is what you want the label of the root attribute to be. The childrenAttrs is how you tell the Tree where a specific node's children are.
I'm not sure what you're trying to do in your code though since your data doesn't seem to have PSS010010026024 in it but I would recommend checking out the API documentation for the ForestTreeModel here: http://dojotoolkit.org/api/?qs=1.9/dijit/tree/ForestStoreModel