Karate; Object type not being throws TypeError as “not an Object”2019 Community Moderator ElectionKarate @RunWith(Karate.class) throwing ErrorKarate data driven with xml and sonWhat's the lifecycle of the 'karate' object?Karate array field become objectEnabling feature specific property in KarateKarate Cucumber Runner throws “No Such Method”Response object templates in KarateTypeError: karate.map is not a function - Karatekarate- run time error in evaluation of 'karate-config.js'Karate 0.9.1 is throwing exceptions for soap webservice testing

How do I deal with a powergamer in a game full of beginners in a school club?

Grey hair or white hair

Could you please stop shuffling the deck and play already?

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

Is it true that real estate prices mainly go up?

Why does the negative sign arise in this thermodynamic relation?

Built-In Shelves/Bookcases - IKEA vs Built

PTIJ: Why can't I eat anything?

Why is this plane circling around the Lucknow airport every day?

Make a transparent 448*448 image

How does airport security verify that you can carry a battery bank over 100 Wh?

A question on the ultrafilter number

How much stiffer are 23c tires over 28c?

Should QA ask requirements to developers?

Accountant/ lawyer will not return my call

Do f-stop and exposure time perfectly cancel?

Fourth person (in Slavey language)

Do I really need to have a scientific explanation for my premise?

Why would one plane in this picture not have gear down yet?

What are some noteworthy "mic-drop" moments in math?

Aliens englobed the Solar System: will we notice?

What is wrong with Escaped Shapeshifter's original wording?

Rejected in 4th interview round citing insufficient years of experience

Should I take out a loan for a friend to invest on my behalf?



Karate; Object type not being throws TypeError as “not an Object”



2019 Community Moderator ElectionKarate @RunWith(Karate.class) throwing ErrorKarate data driven with xml and sonWhat's the lifecycle of the 'karate' object?Karate array field become objectEnabling feature specific property in KarateKarate Cucumber Runner throws “No Such Method”Response object templates in KarateTypeError: karate.map is not a function - Karatekarate- run time error in evaluation of 'karate-config.js'Karate 0.9.1 is throwing exceptions for soap webservice testing










1















With my testing I am looking to do some evaluating on json objects within an array. The example looks like this:



"sections": [

"internal_id": 10635,
"uuid": "a56357fa-fbe6-BARS-89d4-8e8fdbda18b0",
,

"internal_id": 10636,
"uuid": "33a4c634-BARS-4b20-ac3d-54370b32d989",
,

"internal_id": 10637,
"uuid": "99443ce8-5007-4ec2-BARS-b459df30d33b",
,

"internal_id": 10638,
"uuid": "4a54a868-1bfa-BAZZ-93b1-d95a4b529cdf",

]


While doing some debugging I did this:



* print typeof(sections[0]) => this comes back saying object



I have tried to evaluate individual objects doing this:



* eval Object.keys(sections[0]).length; => this comes back with TypeError: <object_at_index_0> is not an Object in <eval>



I don't have a lot of experience with JS, but could someone help me out with this?










share|improve this question






















  • what do you want to validate from this JSON Array ??

    – Babu Sekaran
    Mar 6 at 17:13











  • @BabuSekaran all yours :)

    – Peter Thomas
    Mar 6 at 17:28











  • @BabuSekaran, I would like to validate that the length of the object is 2. Or, basically validate that each object within the JSON array is the same size. In my debugging before writing out an assertion, this threw me as to why I couldn't evaluate the object even though the type was listed as an object

    – kmancusi
    Mar 6 at 21:17















1















With my testing I am looking to do some evaluating on json objects within an array. The example looks like this:



"sections": [

"internal_id": 10635,
"uuid": "a56357fa-fbe6-BARS-89d4-8e8fdbda18b0",
,

"internal_id": 10636,
"uuid": "33a4c634-BARS-4b20-ac3d-54370b32d989",
,

"internal_id": 10637,
"uuid": "99443ce8-5007-4ec2-BARS-b459df30d33b",
,

"internal_id": 10638,
"uuid": "4a54a868-1bfa-BAZZ-93b1-d95a4b529cdf",

]


While doing some debugging I did this:



* print typeof(sections[0]) => this comes back saying object



I have tried to evaluate individual objects doing this:



* eval Object.keys(sections[0]).length; => this comes back with TypeError: <object_at_index_0> is not an Object in <eval>



I don't have a lot of experience with JS, but could someone help me out with this?










share|improve this question






















  • what do you want to validate from this JSON Array ??

    – Babu Sekaran
    Mar 6 at 17:13











  • @BabuSekaran all yours :)

    – Peter Thomas
    Mar 6 at 17:28











  • @BabuSekaran, I would like to validate that the length of the object is 2. Or, basically validate that each object within the JSON array is the same size. In my debugging before writing out an assertion, this threw me as to why I couldn't evaluate the object even though the type was listed as an object

    – kmancusi
    Mar 6 at 21:17













1












1








1








With my testing I am looking to do some evaluating on json objects within an array. The example looks like this:



"sections": [

"internal_id": 10635,
"uuid": "a56357fa-fbe6-BARS-89d4-8e8fdbda18b0",
,

"internal_id": 10636,
"uuid": "33a4c634-BARS-4b20-ac3d-54370b32d989",
,

"internal_id": 10637,
"uuid": "99443ce8-5007-4ec2-BARS-b459df30d33b",
,

"internal_id": 10638,
"uuid": "4a54a868-1bfa-BAZZ-93b1-d95a4b529cdf",

]


While doing some debugging I did this:



* print typeof(sections[0]) => this comes back saying object



I have tried to evaluate individual objects doing this:



* eval Object.keys(sections[0]).length; => this comes back with TypeError: <object_at_index_0> is not an Object in <eval>



I don't have a lot of experience with JS, but could someone help me out with this?










share|improve this question














With my testing I am looking to do some evaluating on json objects within an array. The example looks like this:



"sections": [

"internal_id": 10635,
"uuid": "a56357fa-fbe6-BARS-89d4-8e8fdbda18b0",
,

"internal_id": 10636,
"uuid": "33a4c634-BARS-4b20-ac3d-54370b32d989",
,

"internal_id": 10637,
"uuid": "99443ce8-5007-4ec2-BARS-b459df30d33b",
,

"internal_id": 10638,
"uuid": "4a54a868-1bfa-BAZZ-93b1-d95a4b529cdf",

]


While doing some debugging I did this:



* print typeof(sections[0]) => this comes back saying object



I have tried to evaluate individual objects doing this:



* eval Object.keys(sections[0]).length; => this comes back with TypeError: <object_at_index_0> is not an Object in <eval>



I don't have a lot of experience with JS, but could someone help me out with this?







automation karate






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 6 at 16:21









kmancusikmancusi

31719




31719












  • what do you want to validate from this JSON Array ??

    – Babu Sekaran
    Mar 6 at 17:13











  • @BabuSekaran all yours :)

    – Peter Thomas
    Mar 6 at 17:28











  • @BabuSekaran, I would like to validate that the length of the object is 2. Or, basically validate that each object within the JSON array is the same size. In my debugging before writing out an assertion, this threw me as to why I couldn't evaluate the object even though the type was listed as an object

    – kmancusi
    Mar 6 at 21:17

















  • what do you want to validate from this JSON Array ??

    – Babu Sekaran
    Mar 6 at 17:13











  • @BabuSekaran all yours :)

    – Peter Thomas
    Mar 6 at 17:28











  • @BabuSekaran, I would like to validate that the length of the object is 2. Or, basically validate that each object within the JSON array is the same size. In my debugging before writing out an assertion, this threw me as to why I couldn't evaluate the object even though the type was listed as an object

    – kmancusi
    Mar 6 at 21:17
















what do you want to validate from this JSON Array ??

– Babu Sekaran
Mar 6 at 17:13





what do you want to validate from this JSON Array ??

– Babu Sekaran
Mar 6 at 17:13













@BabuSekaran all yours :)

– Peter Thomas
Mar 6 at 17:28





@BabuSekaran all yours :)

– Peter Thomas
Mar 6 at 17:28













@BabuSekaran, I would like to validate that the length of the object is 2. Or, basically validate that each object within the JSON array is the same size. In my debugging before writing out an assertion, this threw me as to why I couldn't evaluate the object even though the type was listed as an object

– kmancusi
Mar 6 at 21:17





@BabuSekaran, I would like to validate that the length of the object is 2. Or, basically validate that each object within the JSON array is the same size. In my debugging before writing out an assertion, this threw me as to why I couldn't evaluate the object even though the type was listed as an object

– kmancusi
Mar 6 at 21:17












1 Answer
1






active

oldest

votes


















3














You can write an expected schema for a single JSON object and then use match each to validate it for all the data in the JSON Array.



* def sectionArray =
"""

"sections": [

"internal_id": 10635,
"uuid": "a56357fa-fbe6-BARS-89d4-8e8fdbda18b0",
,

"internal_id": 10636,
"uuid": "33a4c634-BARS-4b20-ac3d-54370b32d989",
,

"internal_id": 10637,
"uuid": "99443ce8-5007-4ec2-BARS-b459df30d33b",
,

"internal_id": 10638,
"uuid": "4a54a868-1bfa-BAZZ-93b1-d95a4b529cdf",

]

"""
* match each sectionArray.sections == "internal_id":"#present","uuid":"#present"


You can also validate the size of the array by,



* match sectionArray.sections == "#[4]"


Refer Fuzzy Matching






share|improve this answer




















  • 1





    Okay, so, as I understand it, by doing a match for "#present" on both keys, this asserts that it will fail if there is ONE key or if there are > 2 keys per object?

    – kmancusi
    Mar 7 at 14:04







  • 2





    Each JSON object should exactly have only internal_id and uuid key, any other case would fail.

    – Babu Sekaran
    Mar 7 at 14:51










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55027740%2fkarate-object-type-not-being-throws-typeerror-as-not-an-object%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














You can write an expected schema for a single JSON object and then use match each to validate it for all the data in the JSON Array.



* def sectionArray =
"""

"sections": [

"internal_id": 10635,
"uuid": "a56357fa-fbe6-BARS-89d4-8e8fdbda18b0",
,

"internal_id": 10636,
"uuid": "33a4c634-BARS-4b20-ac3d-54370b32d989",
,

"internal_id": 10637,
"uuid": "99443ce8-5007-4ec2-BARS-b459df30d33b",
,

"internal_id": 10638,
"uuid": "4a54a868-1bfa-BAZZ-93b1-d95a4b529cdf",

]

"""
* match each sectionArray.sections == "internal_id":"#present","uuid":"#present"


You can also validate the size of the array by,



* match sectionArray.sections == "#[4]"


Refer Fuzzy Matching






share|improve this answer




















  • 1





    Okay, so, as I understand it, by doing a match for "#present" on both keys, this asserts that it will fail if there is ONE key or if there are > 2 keys per object?

    – kmancusi
    Mar 7 at 14:04







  • 2





    Each JSON object should exactly have only internal_id and uuid key, any other case would fail.

    – Babu Sekaran
    Mar 7 at 14:51















3














You can write an expected schema for a single JSON object and then use match each to validate it for all the data in the JSON Array.



* def sectionArray =
"""

"sections": [

"internal_id": 10635,
"uuid": "a56357fa-fbe6-BARS-89d4-8e8fdbda18b0",
,

"internal_id": 10636,
"uuid": "33a4c634-BARS-4b20-ac3d-54370b32d989",
,

"internal_id": 10637,
"uuid": "99443ce8-5007-4ec2-BARS-b459df30d33b",
,

"internal_id": 10638,
"uuid": "4a54a868-1bfa-BAZZ-93b1-d95a4b529cdf",

]

"""
* match each sectionArray.sections == "internal_id":"#present","uuid":"#present"


You can also validate the size of the array by,



* match sectionArray.sections == "#[4]"


Refer Fuzzy Matching






share|improve this answer




















  • 1





    Okay, so, as I understand it, by doing a match for "#present" on both keys, this asserts that it will fail if there is ONE key or if there are > 2 keys per object?

    – kmancusi
    Mar 7 at 14:04







  • 2





    Each JSON object should exactly have only internal_id and uuid key, any other case would fail.

    – Babu Sekaran
    Mar 7 at 14:51













3












3








3







You can write an expected schema for a single JSON object and then use match each to validate it for all the data in the JSON Array.



* def sectionArray =
"""

"sections": [

"internal_id": 10635,
"uuid": "a56357fa-fbe6-BARS-89d4-8e8fdbda18b0",
,

"internal_id": 10636,
"uuid": "33a4c634-BARS-4b20-ac3d-54370b32d989",
,

"internal_id": 10637,
"uuid": "99443ce8-5007-4ec2-BARS-b459df30d33b",
,

"internal_id": 10638,
"uuid": "4a54a868-1bfa-BAZZ-93b1-d95a4b529cdf",

]

"""
* match each sectionArray.sections == "internal_id":"#present","uuid":"#present"


You can also validate the size of the array by,



* match sectionArray.sections == "#[4]"


Refer Fuzzy Matching






share|improve this answer















You can write an expected schema for a single JSON object and then use match each to validate it for all the data in the JSON Array.



* def sectionArray =
"""

"sections": [

"internal_id": 10635,
"uuid": "a56357fa-fbe6-BARS-89d4-8e8fdbda18b0",
,

"internal_id": 10636,
"uuid": "33a4c634-BARS-4b20-ac3d-54370b32d989",
,

"internal_id": 10637,
"uuid": "99443ce8-5007-4ec2-BARS-b459df30d33b",
,

"internal_id": 10638,
"uuid": "4a54a868-1bfa-BAZZ-93b1-d95a4b529cdf",

]

"""
* match each sectionArray.sections == "internal_id":"#present","uuid":"#present"


You can also validate the size of the array by,



* match sectionArray.sections == "#[4]"


Refer Fuzzy Matching







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 7 at 15:14

























answered Mar 7 at 2:57









Babu SekaranBabu Sekaran

2,1411318




2,1411318







  • 1





    Okay, so, as I understand it, by doing a match for "#present" on both keys, this asserts that it will fail if there is ONE key or if there are > 2 keys per object?

    – kmancusi
    Mar 7 at 14:04







  • 2





    Each JSON object should exactly have only internal_id and uuid key, any other case would fail.

    – Babu Sekaran
    Mar 7 at 14:51












  • 1





    Okay, so, as I understand it, by doing a match for "#present" on both keys, this asserts that it will fail if there is ONE key or if there are > 2 keys per object?

    – kmancusi
    Mar 7 at 14:04







  • 2





    Each JSON object should exactly have only internal_id and uuid key, any other case would fail.

    – Babu Sekaran
    Mar 7 at 14:51







1




1





Okay, so, as I understand it, by doing a match for "#present" on both keys, this asserts that it will fail if there is ONE key or if there are > 2 keys per object?

– kmancusi
Mar 7 at 14:04






Okay, so, as I understand it, by doing a match for "#present" on both keys, this asserts that it will fail if there is ONE key or if there are > 2 keys per object?

– kmancusi
Mar 7 at 14:04





2




2





Each JSON object should exactly have only internal_id and uuid key, any other case would fail.

– Babu Sekaran
Mar 7 at 14:51





Each JSON object should exactly have only internal_id and uuid key, any other case would fail.

– Babu Sekaran
Mar 7 at 14:51



















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55027740%2fkarate-object-type-not-being-throws-typeerror-as-not-an-object%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved